Joseph Jude

Technology, Psychology, and Story Telling

Git mirroring

Posted: Tags: code

I have two code repositories. I have a public repository at Github. I have another repository hosted on my server. I use Gogs for my private repository. (If you are interested in Gogs, check out my guide on installing Gogs on webfaction).

With this dual setup, I have all my code (private and public) in one place; as well as, I can choose to share pieces of code with others via Github.

Even if you have all your code out in public, you should still have two repositories so that one can serve as a backup.

The steps for git mirroring are:

Create the repository (in gogs & in github)

Nothing big deal here. Just create a repository in both places. In all the below discussions, gogs is the primary repository and github is the secondary repository.

Clone the gogs repository to your local machine

git clone

Add github repository as a remote

Go into your local repository directory and add the github repository.

cd swift-ios-apps/
git remote add github

If you issue git remote -v locally, it will list the remote repositories. You can push to this repository by issuing git push --mirror github. I wanted all my git pushes to be immediately pushed to both repositories. So I edited git config.

Edit git config

Edit .git/config in the local directory (swift-ios-apps in this case). Add a remote all section similar to the below lines:

[remote "all"]
    url =
    url =

Push to both repository

You can issue git push all to push to both repository.

Like the post? Retweet it. Got comments? Reply.


comments powered by Disqus