Reputation: 32919
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?
Upvotes: 3
Views: 260
Reputation: 17916
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 [email protected]: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.
Upvotes: 1