Skip to content

Instantly share code, notes, and snippets.

@MarcL
Last active January 15, 2019 16:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcL/a4de4ebd545ee1a5aef2ed31a4284b02 to your computer and use it in GitHub Desktop.
Save MarcL/a4de4ebd545ee1a5aef2ed31a4284b02 to your computer and use it in GitHub Desktop.
Move a BitBucket repository to GitHub

Move BitBucket repository to GitHub

As GitHub is now giving unlimited free private repositories to all users, you might want to move some of your private repositories to GitHub. Here's how you do it.

Create a new GitHub project

Find your local repository

This will be where you've checked out your BitBucket project:

cd $HOME/local-repo

Rename the BitBucket remote

Your BitBucket repository was probably origin so you'll want to rename it

git remote rename origin bitbucket

Add the GitHub remote repository

Remember to change YOUR-USERNAME and NEW-REPOSITORY-NAME to the your own username and the name of the repository you created earlier.

If you're using SSH keys then use this:

git remote add origin git@github.com:YOUR-USERNAME/NEW-REPOSITORY-NAME.git

If you're using HTTPS then use this:

git remote add origin https://github.com/YOUR-USERNAME/NEW-REPOSITORY-NAME.git

Push your code to GitHub

git push origin master

Update your local branch to track GitHub

Your local branch will still be tracking the BitBucket remote. You can see this by using the following command:

git branch -vv

Update your branch to use the GitHub remote repository with:

git branch -u origin/master

Optional : Delete your BitBucket remote

If you look at your remote repositories, you'll see that you have both BitBucket and GitHub:

git remote -v

You can leave this if you still want to push code to BitBucket. If you don't then delete it with the following:

git remote rm bitbucket

Shout if you spot any issues with the above. Thanks.

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