3

Our team has been adding new members lately. Every time we add a new person, they get their own remote Git repository. The number of remotes in the .git/config for each project goes up by one. Every single person on the team needs to add the new remote to every project. The new person has to add the remotes for every existing team member when they initially clone the project.

This is very annoying. Is there some way to automatically add all the appropriate remotes to all the projects to eliminate this hassle?

Apreche
  • 30,042
  • 8
  • 41
  • 52
  • 3
    Why do you have one remote repository for each team member? – 1615903 Oct 03 '13 at 14:45
  • 2
    Why bother? Anybody that wants to talk to Alice's repo can just add the remote on the fly, using whatever you're using now when bulk-adding them all up front. for extra added convenience hunt up how to make a git alias and make a `git remotefor Alice` that's idempotent. – jthill Oct 03 '13 at 14:45

1 Answers1

1

Just write a shell script which ensures that all the remotes are present, and then share that with the team either by checking it into the repository or making it available out of band.

If you want, you can reuse some shell functions which I already wrote for managing git remotes, e.g.:

# clone the above repo to some $MR_CONFIG_REPO first
source $MR_CONFIG_REPO/sh.d/git-remotes
for developer in alice bob charles dave; do
    git_add_remote $developer https://github.com/$developer/$PROJECT_NAME.git
done

# or if the repo URLs don't follow a pattern
git_add_remotes "
    alice   https://github.com/alice/$PROJECT_NAME.git
    bob     https://src.bob.com/git/$PROJECT_NAME.git
    charles file:///mnt/nfs/git/$PROJECT_NAME.git
    dave    git@github.com:dave/${PROJECT_NAME}-2.git
"

If you want to get more sophisticated, you can steal more ideas from my mr configuration repository, in particular this file. mr is a pretty handy tool for batch management of repositories, and I have been using it extensively for quite a long time now.

Adam Spiers
  • 17,397
  • 5
  • 46
  • 65