Skip to content

Setting up Git "mirrors"

Alexander Grüneberg edited this page May 3, 2013 · 3 revisions

Just as it is useful to save important files to your hard drive and to a flash drive for safekeeping, it can be useful to "mirror" your repositories on multiple providers. This page demonstrates how to do this for Banyan, Bitbucket, GitHub, and Google Code.

  1. Start by creating a repository on GitHub.
  2. Import to Bitbucket.org directly by importing from GitHub.
  3. Create a project on Google Code and push your repository to the address given there.
  4. Create a project on Banyan and push your repository to the address given there.

This strategy of mirroring repositories on Banyan, Bitbucket, GitHub, and Google Code is very convenient if you use the "git remote add" feature. This feature allows you to set aliases so you can push a particular branch "branch" to a particular host "host1" by saying "git push host1 branch". You can then turn around in the very next line and push it to "host2" trivially. A concrete example is given for QMachine, but you should change the URLs to match your own project's URLs. (Duh.)

$ git remote add banyan git@banyan.co:wilkinson/qmachine.git
$ git remote add bitbucket https://bitbucket.org/wilkinson/qmachine.git
$ git remote add github https://github.com/wilkinson/qmachine.git
$ git remote add googlecode https://sean%40mathbiol.org@code.google.com/p/qmachine/

The first one, given for Banyan, uses the Git protocol. This is sometimes more pain that it's worth, because it uses SSH keys, which aren't very much fun to set up. Sometimes at our hospital, you can't use SSH from certain networks anyway, which is part of why it's so useful to be able to push to a different mirror temporarily so that you know your work is safe.

Clone this wiki locally