Skip to content

Instantly share code, notes, and snippets.

@erictompkins
Last active May 1, 2020 12:48
Show Gist options
  • Save erictompkins/624ca2109e56ef795a282ccf622910eb to your computer and use it in GitHub Desktop.
Save erictompkins/624ca2109e56ef795a282ccf622910eb to your computer and use it in GitHub Desktop.
Migration from BitBucket to Github

How to migrate a Git repository from BitBucket to GitHub

  1. Create the new repository in GitHub.

  2. Make sure that you've checked out the code to your computer.

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

Or, if you already have the code checked out just pull.

git pull
  1. Navigate to the folder for the repository on your computer in your terminal.
cd PROJECT
  1. Add the GitHub repository as a new remote for the project. gh is just a name for the remote. We'll change it later.
git remote add gh [email protected]:USER/PROJECT.git

If you want to confirm the list of remotes.

git remote -v
  1. Push the master branch to GitHub.
git push gh master
  1. Push all tags to GitHub
git push --tags gh
  1. Check the GitHub repository and make sure that it has all the data.

  2. Remove the BitBucket remote on your computer. We're assuming that the remote name is origin.

git remote remove origin
  1. Rename the gh GitHub remote to origin. This is more of a personal preference and not necessary. But since it's common to call a remote origin this doesn't hurt.
git remote rename gh origin
  1. Remove the repository in BitBucket
  • Go to the BitBucket web interface and log in.
  • Open the repository.
  • Go to Repository Settings
  • At the bottom of that page click on the Delete Repository button.
  • If desired put in the URL of the GitHub repostiory into the URL to new location field when confirming the deletion.

Resources

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