4

Do I have to define remotes on each machine that clones a repository? Is there any concept of pushing a remote so that anyone that clones the repository has more than just the origin?

(Besides creating a script that is included in the repository that gets run to create them)

Edit------

So my motivation for this question is that I have a public github repository and a private repository. The private differs from the public in that it contains an additional private submodule that has custom configuration details such as passwords.

I will only ever change the private configuration repository. Anytime I push to the public github repo, I also want them to go to the private repo.

Community
  • 1
  • 1
jgrowl
  • 2,117
  • 2
  • 17
  • 23
  • http://stackoverflow.com/questions/849308/pull-push-from-multiple-remote-locations – René Höhle Sep 25 '13 at 21:14
  • Can you even do that? The private repo will have a different commit history so you would have to do a merge, which I didn't think you could do on a push, only a pull. – tacaswell Sep 25 '13 at 21:47
  • 1
    tcaswell, that is correct. That is part of the problem. I was trying to get jenkins to pull the changes but I'd have to configure the remote branches on my jenkins server. I am trying to avoid manual configuration. – jgrowl Sep 25 '13 at 21:48
  • Is there some kind of hook Git will do right after a repo is cloned? If so, maybe you can write a custom script that adds remotes and have that hook in when the repo is cloned. – Sarah Vessels Sep 25 '13 at 21:53

2 Answers2

2

No. You can document or script them in the repository, but git doesn't provide any way transfer information on remotes when normally cloning or pulling a repo.

However - cloning a repository with --mirror does include remotes, though this option implies --bare, which may not be what you want.

borntyping
  • 2,931
  • 2
  • 23
  • 30
1

So you want to change the default behaviour, which automatically creates the default remote to origin, to create more branches..

I am not sure about how to solve this, but you can rename your default remote branch, add other remotes and setting up more tracking branches too.

You do not clone remotes of a repository.

Conceptionally repository's remotes are handled by their owner. If you have cloned the repository, you should add more remotes to it later. Remotes are just some subdirectories under your .git folder, where you can track remote repositories for your own. (.git/refs/remotes/*/) You can fetch them, than track them with your locals.

Sorry if it was not helpful.

Maybe you should check something like git clone --recurse-submodules .

kisp
  • 6,402
  • 3
  • 21
  • 19