How To Move off GitHub

If you want to leave Github for whatever reason, you probably want to take all your code with you, and all your history and branches, etc.

Here's an example for how I moved my Android Eclipse workspace from Github to my own remote server.

First I make a new git repo on my remote server:

$ git --bare init ~/git/workspace

The --bare option means I'm not going to work on the code in the remote git repo directly.

Next I push my current local 'master' to the new repo:

$ git checkout master
$ git push ssh:// master

After that I push my working branch:

$ git checkout work
$ git push ssh:// work

You could repeat this step if you have more branches.

I created my local repo using 'clone' so it has an 'origin' remote branch defined. This 'remote' branch is where git fetches and pushes changes.

Right now my 'fetch' and 'push' remote origins point to Github:

$ git remote -v (fetch) origin (push)

So I remove my 'origin' and add the new one:

$ git remote rm origin
$ git remote add origin ssh://

Then I update my local master's 'remote' to the new 'origin':

$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master

After this change I can automatically push my commits to the new repo, 'origin' is now selected as my default 'remote' for 'master' :)

$ git remote -v
ssh:// (fetch) origin
ssh:// (push)
$ git push
$ git pull

git (3) github (1)