Current Articles | RSS Feed RSS Feed

Personal Github Mirroring in 3 Steps

Posted by Michael Chletsos on Thu, Jun 27, 2013

Github Repository Backup

Github is a great service and very reliable, but your code is so precious you back it up in several places just in case it is unavailable when you need it most. Occasionally, Github does go down, it’s a fact of life. With Github having 99.69% uptime over the past year, that means about 27 hours a year your code is unavailable. It is time to get that code elsewhere, so you can continue working without any hiccups. An easy way to always be moving forward and collaborating while Github is getting back up and running is to use a free Assembla repo as a mirror.

A mirror is a duplicate of your work. It is a point in time, just as most backups are not real-time, the mirror must be pushed to in order to get back in sync.  If you end up pushing data directly to an Assembla mirror while Github is unavailable, you will have to sync (push) that data back to Github once it becomes available again.  The mirror is just another fork of your data, that must be maintained and updated regularly.  

To setup a mirror from a local repo, all you have to do is add a remote to your git repo and then push to it with the --mirror flag. By using the --mirror flag in your push, all references and branches are pushed, it’s a complete backup. Any Assembla repo will work without any special setup, using an empty repo tool is easiest.

Remember, you will control when the mirror is updated, so you must push to this new remote each time you want to sync from your local repo to your mirror and push to your Github repository as well. I will show you how to make a nice trick for this as well at the end.


1. Clone your Github repo locally


2. Add the remote Assembla repo to your local Git repo

# git remote add assembla_mirror<ASSEMBLA_REPONAME>.git

3. Push to your Assembla mirror repo

# git push --mirror assembla_mirror 

github mirror

Now you can view your mirror in the online repo browser or pull and push to the remote mirror as necessary from your favorite client.

Remote Push Trick:

Let’s say you want to always push to both remotes, your Github and your Assembla remote, at the same time.  You can do this with a quick change to your .git/config file.  Just create a section like this:

[remote “all”]
        url =
        url =

Now you can just push like this and keep everything up to date:

# git push all

Notes to Remember:

  • This is a mirror of your local repository to Assembla, ensure that your local repository is up to date before pushing up to Assembla.
  • This is an asynchronous mirror, you must push up to Assembla to get the data there.
  • If there is a conflict, you must resolve it before the push will be successful. hint: checkout the remote Assembla repository and update as necessary or just remove and add a new one.
  • If you push to your Assembla repository, you must remember to update your Github repository.
  • Using --mirror pushes all refs and branches up to the repository, you can push just a branch without --mirror and adding the ref to the end of the command
  • Only your repository will be available in Assembla, not your Github discussions, wiki nor other features of Github will be available.


Get Started with a Free Hosted Git Repo from the Assembla plans page.

Tags: ,


There are no comments on this article.
Comments have been closed for this article.

Follow Assembla

twitter facebook youtube linkedin googleplus

Subscribe by Email

Your email: