Automatically push commits from your repo to GitHub
If you have your git repositories on your own server, but want to mirror them on github, then this might be relevant for you.
Assume that you push your work to machine myhost via ssh. You want to mirror myrepo to github.
1. Generate ssh key and upload it to github
If the user you use to access your repos already has ssh key generated, skip the generation part.
user@myhost$ ssh-keygen -t rsa
You need to either make use of ssh-agent or use empty passphrase. Now copy the
~user/.ssh/id_rsa.pub and paste them
2. Create empty repository on github
3. Add github as a remote
user@myhost$ cd git/myrepo.git/ user@myhost$ git remote add --mirror github firstname.lastname@example.org:user/myrepo.git
Push the current contents:
user@myhost$ git push github
4. Set up post-receive hook
hooks/post-receive and make it look like this. (
work as well, but mine does
update-server-info so why not use the other ...)
Don't forget to make it executable.
#!/bin/sh git push --quiet github
Now whenever you push your changes to myrepo at myhost, they should also magically appear at github.