Managing many git repositories
Setting up a project is easy in git and so I can have separate repository even for small script. Now the problem is how to manage them.
I work in multiple places with these repositories. When I have done changes to some repository, I want to be able to update the repositories in other places.
So I have a directory with many repositories in it.
- How can I fetch all of them?
- How can I check whether any of them have uncommitted changes?
- How can I check whether any of them have changes to merge?
And it would be nice to be able to do these with one command.
The output needs to be silent enough to actually notice the things to do.
Solution 1:
I highly recommend the multiple repositories tool mr. I used to use a custom shell script as recommended by others for some time, but using mr has the following benefits for me:
- It's generic: A conjunction of various version control systems can be used, not only git (e.g. Mercurial, SVN, etc.).
- It's fast: mr can execute multiple jobs in parallel. I use a number of git/mercurial repositories and sync them several times a day. Mr tremendously speeds up this process.
- It's easy and quick to manage the list of repository checkouts. Just use 'mr register' rather than modifying the list of projects in your custom script.
Regarding to your question about silent output: The level of verbosity can be modified using the command line switch -q. I prefer the default output which appears to nicely unify the output in a short and clear summary.
I use the following alias for the mr command to ensure that mr always picks up my default project list stored in $HOME, and uses 5 parallel threads:
alias mr='mr -d ~/ -j 5 '
Solution 2:
I must say I started with the currently accepted answer (just a bunch of helpers scripts that iterate over the repositories), but all in all, it was a lacking experience for me.
So, after trying mr, repo and git-submodules, I found each lacking in a different way, so, I ended up doing my own variant: http://fabioz.github.io/mu-repo which is a mature tool at this point -- it has workflows which allow you to:
- clone multiple repos
- diff (and edit) current changes in multiple repos
- preview incoming changes
- run commands in multiple repos in parallel
- create groups of repos
- run non git-related commands over multiple repos
- etc (see homepage for more info).
Note that it supports any OS where Python runs ;)