3

Lets say I have a repository on a server somewhere (call it "origin") which has remotes pointing somewhere else (lets call that server "parent").

When cloning origin to my local PC, is there a way to automatically create a remote on my local machine pointing to parent (in addition to the remote pointing to origin)?

2
  • IME that's not possible.
    – Sathyajith Bhat
    Aug 11, 2011 at 8:58
  • @Sathya: is is possible under certain condition. See my answer.
    – VonC
    Aug 11, 2011 at 9:21

1 Answer 1

2

The remotes are declared in the local config file of a git repo.
And config file is never shared amongst cloned repo.

So unless you have:

  • those remote names and addresses in a file with a recognizable content
  • a .gitattributes filter driver able to trigger a smudge scruipt on checkout:

(The "recognizable" requirement is there because a filter script has only the content of a file in input, not its name or path)

smudge

That smudge script will then be able to:

  • read the remote name and addresses you want to declare
  • check if a remote name isn't already there
  • if not, will add that remote.

My point is: you need to extract that config information (the remotes, which, like all configs, are never shared) into a file, managed in the Git repo.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .