migrate from github to bitbucket

How to Migrate from GitHub to BitBucket

GitHub and BitBucket are two popular cloud-based services that allow you to store code and documents. Both provide tons of services but have quite different pricing plans. So sometimes you may need to migrate your repositories from GitHub to Bitbucket because their plans might be more suitable for your requirements. In this article, we will learn how to migrate from GitHub to Bitbucket.

How to Migrate from GitHub to BitBucket

Here are the steps to migrate from GitHub to BitBucket.

1. Import from GitHub to BitBucket

Log into your BitBucket account. Click Repositories and then click Import Repository.

From dropdown labelled Source, select Git.

Check the Checkbox labelled ‘Require Authentication’. Enter username and password of your GitHub Account. You may get an error saying Authentication Denied, that you can ignore for now.

Copy the URL of your GitHub Repo. It should be of the format as shown below.


You can find it in the right hand column under HTTPS URL of GitHub. Log into your GitHub account to get it. Add the copied URL to the above form’s URL textbox.

Some of the fields under New Repository will be automatically filled in including the name. Update the name, description and other settings as per your requirement.

Click Import Repository to start the import process.

2. Change Origin URL

Both GitHub and Bitbucket work on version control software. The local copy of the repository on your local system will still be pointing to the remote repository in GitHub. We need to make it to point to BitBucket so that future pushes happen to the new repository in BitBucket. Otherwise, they will continue to go to your GitHub repository instead.

On your local system’s command line, go to the folder that contains your repository and run the following command.

$ git remote -v

It will show that your remote repository is still in GitHub.

origin https://USERNAME@github.com/USERNAME/REPONAME.git (fetch) 
origin https://USERNAME@github.com/USERNAME/REPONAME.git (push)

To change this, edit the git configuration file on your local system by opening it in a file editor.

$ sudo vi .git/config

Under remote “origin” change github.com to bitbucket.com. If you are using a different username in BitBucket than what you have on GitHub you may need to change that too. Basically you need to change from GitHub’s repo URL to the repo URL in BitBucket.


3. Delete GitHub Repo

Once you have tested your new repository, you can log into GitHub and delete the old repository. Log into GitHub, go to your repo, go to settings and click delete repo.

If you want to migrate multiple repositories from GitHub to BitBucket, you need to repeat the above steps for each repository.

Also read:

How to Transfer All MySQL Databases from One Server to Another
How to List All Virtual Hosts in NGINX
How to Remove Docker Images, Containers & Volumes
How to Rebuild RPM Database in Linux
How to Modify URL Without Page Refresh in JS

Leave a Reply

Your email address will not be published.