Skip to content

Instantly share code, notes, and snippets.

@lsloan
Forked from mandiwise/Update remote repo
Last active March 20, 2024 15:41
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save lsloan/ce704da0d62ce3808dbc12e5a37ba8fc to your computer and use it in GitHub Desktop.
Save lsloan/ce704da0d62ce3808dbc12e5a37ba8fc 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

@vineeshvs
Copy link

Do these imports maintain issues, commit history, etc.?

@Neemrode
Copy link

Great work

@aivarasgo
Copy link

yes, that's a bulletproof way, repository after copy contains commit history, tags, branches, etc..

@lsloan
Copy link
Author

lsloan commented Nov 29, 2021

@vineeshvs: It includes all commit history. It doesn't include issues. See the last section of my document for a link about doing that.

@aivarasgo: Thanks! 🙂

Note to self: Revise this to make the examples more general.

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