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)
- See: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
- See also: http://www.paulund.co.uk/change-url-of-git-repository
⚠️ 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 firstname.lastname@example.org:giovannipizzi/aiida_core_test.git $ git push --mirror