Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

  1. How can I fetch all of them?
  2. How can I check whether any of them have uncommitted changes?
  3. 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.

like image 476
iny Avatar asked May 03 '09 09:05

iny


People also ask

Can you have multiple repositories in git?

With Git, using multiple repositories is the only way to work efficiently. This enables each team to work independently, and do their work faster. You can also make sure that developers only have access to the repositories they need access to (thus making Git more secure.)

How many Git repositories can I have?

We're excited about these updates to our Free and Enterprise offerings: GitHub Free now includes unlimited private repositories. For the first time, developers can use GitHub for their private projects with up to three collaborators per repository for free.


2 Answers

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 ' 
like image 195
Sandro Giessl Avatar answered Oct 06 '22 06:10

Sandro Giessl


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

like image 32
Fabio Zadrozny Avatar answered Oct 06 '22 05:10

Fabio Zadrozny