How to move git repository with all branches from bitbucket to github?

It's very simple.

  1. Create a new empty repository in GitHub (without readme or license, you can add them later) and the following screen will show.

  2. In the import code option, paste your Bitbucket repo's URL and voilà!!

Click Import code


You can refer to the GitHub page "Duplicating a repository"

It uses:

  • git clone --mirror: to clone every references (commits, tags, branches)
  • git push --mirror: to push everything

That would give:

git clone --mirror https://bitbucket.org/exampleuser/repository-to-mirror.git
# Make a bare mirrored clone of the repository

cd repository-to-mirror.git
git remote set-url --push origin https://github.com/exampleuser/mirrored
# Set the push location to your mirror

git push --mirror

As Noted in the comments by L S:

  • it is easier to use the Import Code feature from GitHub described by MarMass.
    See https://github.com/new/import
  • Unless... your repo includes a large file: the problem is, the import tool will fail without a clear error message. Only GitHub Support would be able to diagnose what happened.

In case you couldn't find "Import code" button on github, you can:

  1. directly open Github Importer and enter the url. It will look like: Screenshot of github importer
  2. give it a name (or it will import the name automatically)
  3. select Public or Private repo
  4. Click Begin Import

UPDATE: Recently, Github announced the ability to "Import repositories with large files"