Migrating git repo to GitHub

March 21, 2013

Reading time ~1 minute

GitHub is a wonderful service for hosting your Git repositories. In fact it is not only good at hosting repos, in my case it even hosts this blog :). However, we needed to migrate an existing repository from a self-hosted Git installation to GitHub. Here’s the instructions for doing the migration.

The first thing you need to do is to create an empty git repo at GitHub. You do not need to initialize it, just create it. Then clone your existing repo to you local computer:

git clone old-repo.host.com:/var/git/my_repo my_repo
cd my_repo
for branch in $(git branch -r | grep -v HEAD | cut -c 10-) ; do git checkout $branch ; git pull ; done

Add GitHub as a remote

git remote add github git@github.com:avail-labs/avail.git

And push all code and tags to GitHub

git push --force --all github
git push --tags

Note that pushing a big repo to GitHub might take some time. It seems like GitHub is throttling the incoming requests slightly.

You will need to update your local Git configuration to point at GitHub instead of your old repo, when the repo has been pushed to GitHub. This command will do the trick

git remote set-url origin git@github.com:gh-account/gh-repo.git

The URL can be copied from your GitHub repo’s web interface.

Happy coding!

Running vim-airline with Maximum Awesome

I use [Maximum Awesome](https://github.com/square/maximum-awesome) when I code in [vim](http://www.vim.org/), it's a great starting place...… Continue reading

Quicksort implementation in Python

Published on August 04, 2014

Fibonacci generator in Python

Published on August 04, 2014