Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rmi1974/9e06453f1db1b9327933ea5510a97522 to your computer and use it in GitHub Desktop.
Save rmi1974/9e06453f1db1b9327933ea5510a97522 to your computer and use it in GitHub Desktop.
How to manage multiple repositories using myrepos tool #myrepos #git #git-annex #git-bup

How to manage multiple repositories using myrepos tool

myrepos

You have a lot of version control repositories. Sometimes you want to update them all at once. Or push out all your local changes. You use special command lines in some repositories to implement specific workflows. Myrepos provides a mr command, which is a tool to manage all your version control repositories.

myrepos is a command-line tool which adds the mr command to your environment. mr does not care about different version control systems, it supports all of them.

The standard way to use mr is to go into each one of your repositories and run the command mr register for mr to add it to your configuration file in ~/.mrconfig.

For advanced example of myrepos usage, have a look at Adam Spiers' mr config on Github.

Recursive commands

If a command, for example mr update, is run in e.g. ~/projects/wine/mainline-src, then mr only runs it on that repository.

If it is run in the parent, e.g. ~/projects/wine/, then it only runs the update command in all children of that directory. In this case, it would run update in all the Wine project repositories.

If the command is run on a higher level, e.g. in ~/projects then the command applies to all registered repositories in projects/..

Through this hierarchical structure, it is possible to manage all of your repositories using a single configuration file, both personal and work related, simply by running your commands in the relevant directory.

Standard operations

The primary commands you will want to use are:

  • mr checkout clones any repositories which don’t already exist
  • mr update updates all the repositories
  • mr clean prints the ignored/untracked files in repos, use -f to remove files as well
  • mr status shows you the status of each repo; handy to figure out if any repos have pending changes
  • mr diff shows you the diffs from all repos
  • mr run allows you to run an arbitrary command in all repos

Check out the manual of myrepos, it is not long and has some nice tidbits about parallel execution. Alright, I will give up that last one: use the switch mr -j 5 to run 5 concurrent jobs.

Custom operations

This is where the tool starts to shine, not only is this a full-featured repository manager; it also gives you tools to do batch operations across multiple repositories.

Custom commands under the [DEFAULT] section only apply to the repositories which are under that section. This is why all the custom commands are placed at the very top of the .mrconfig file.


Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment