Since I am running a self-hosted Git server, using the powerful software Gitea, and want to use for CI I need to mirror my repositories to GitHub because Travis does not support self-hosted Git. Since I couldn't find an easy and short documentation on how to do this I decided to hack this myself.

Here I show how I did this very easily.


  • A Git repository under /home/git/hanez/helloworld managed by user "git"
  • A HTTP(S) interface for accesing your repository from GitHub like
  • A GitHub account

Import repository to your GitHub account


Become user "git" on your Git server

$ su - git

Generate a SSH key if not already done

$ ssh-keygen

Add the content of ".ssh/" to the deploy keys at GitHub

You can add the public SSH key to the repository at GitHub in the settings of each repository. In this case I use the "hanez/helloworld" repository.

Change directory to bare repository

$ cd /home/git/hanez/helloworld.git

Add "remote" to repository config

$ git remote add --mirror=push github

This will make my "config" look like this:

$ cat config
        repositoryformatversion = 0
        filemode                = true
        bare                    = true
[remote "github"]
        url =
        mirror = true

Create post-receive hook

First change directory

cd hooks/post-receive.d

Create the hook

$ cat <<EOF >> github
#!/usr/bin/env sh
git push --quiet github &

Make the hook executable

$ chmod +x github


You see, it is very easy to mirror your self-hosted Git repository to GitHub. With this configuration your repository will be mirrored on every push to your GitHub account. Now you can use services like Travis-CI or Docker-Hub to rebuild code or containers even when not using GitHub as your primary source code management platform. I believe this is very useful to many so I decided to publish my workflow here.

Hope this is helpful to you... ;)