Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save diegorribeiro/2dcd5cbe53c3f42ea09b2de05e84c396 to your computer and use it in GitHub Desktop.
Save diegorribeiro/2dcd5cbe53c3f42ea09b2de05e84c396 to your computer and use it in GitHub Desktop.
Copy Bitbucket repo to GitHub

Copy Bitbucket repo to GitHub

Whenever possible, use GH's "Import repository" feature.

The import feature doesn't always work, though. In my experience, I tried to import a repo and it failed with a generic message. I had to contact GH support to ask for help. They told me my repo had a large file (>100MB), which couldn't be added to GH directly. I had to either remove the file or store it in GH LFS. In this case, one of the CLI methods below are needed:

CLI: Copy the master branch only (OK)

⚠️ Caution: This method only copies the master branch, not others and not tags.

$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket

CLI: Copy more than master (Better)

$ # create a new public repo "tarfu/fubar" on Github
$ git clone https://bitbucket.org/tarfu/fubar.git
$ cd fubar
$ git remote add https://github.com/tarfu/fubar.git
$ git push upstream master; git push upstream develop; # add more branch pushes as necessary
$ git push --tags upstream

CLI: Copy everything (Best)

ℹ️ Note: This method uses --mirror to copy all branches, tags, etc.

$ git clone --mirror https://bitbucket.org/aiida_team/aiida_core.git
$ cd aiida_core.git
$ git remote set-url --push origin git@github.com:giovannipizzi/aiida_core_test.git
$ git push --mirror

Also helpful: Copy issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment