I have been a happy user of BitBucket for many years due to its free private repositories. However I have always favoured using Github due to more tools and all my opensource projects are hosted in GitHub. Now that github offers free private repositories it was just logical to also move my private repos to github.

Here are the steps to move a Git repository:

Step 1: Create Github repository

First, create a new private repository on Github.com. It’s important to keep the repository empty, e.g. don’t check option Initialize this repository with a README when creating the repository.

Step 2: Move existing content

Next, we need to fill the Github repository with the content from our Bitbucket repository:

Get (checkout) the existing repository from Bitbucket

$ git clone https://[email protected]/USER/PROJECT.git

Add the new Github repository as upstream remote of the repository checked out from Bitbucket

$ cd PROJECT
$ git remote add upstream https://github.com:USER/PROJECT.git
3. Push all branches
$ git push upstream master
$ git push --tags upstream

Step 3: Clean up old repository

Delete the bitbucket repository.