How to mirror a git repository

As I was working on libgnusocial I went into trouble because we have three different git repositories: Gitlab, Github & code.freedombone.net and I wanted to keep them all updated. To do this I just work with one (at Gitlab) and I treat the others as mirrors. First of all, to mirror a git repository we need to clone it using the “mirror” argument:

$ git clone --mirror https://gitlab.com/user/repository

Then move into the cloned repository directory (which git ends in “.git” due to the mirror cloning process):

$ cd repository.git

And finally push into an empty repository or an outdated mirror of our repository:

$ git push --mirror https://gitlab.com/user/another_repository

Leave a Reply