Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)?

share|improve this question
IME that's not possible. – Sathya Aug 11 '11 at 8:58
@Sathya: is is possible under certain condition. See my answer. – VonC Aug 11 '11 at 9:21
@VonC Awesome, thanks for the detailed answer! – Sathya Aug 11 '11 at 9:26
up vote 2 down vote accepted

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)


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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.