How to move private repositories from Github to Bitbucket

Github is a great service and remains the epicentre of open source code. But for a single developer paying for private repositories, its payment plans don't make a lot of sense. This is because they charge by the number of repositories you have. I tend to have quite a few small private repos for various projects, so the cost creeps up pretty quick. I have absolutely no objection paying Github for private repos, but the pricing structure does need to be sensible.

Bitbucket's pricing structure makes a lot more sense. They charge by the number of users, rather than repositories. As a bonus, it is free for up to 5 users. And you get unlimited repositories, a price increase is only triggered by an increase in the number of users. This makes a lot more sense than charging my repositories because it better reflects the size of the organisation. A large organisation with more users will pay more, a smaller organisation with less users will pay less and a single developer will pay nothing without being constrained by the number of repositories. Makes sense right?

Like I said before, I don't mind paying. The fact that bitbucket give it to me for free is a bonus.

Moving repos from Github to Bitbucket

Now down to the meat of this post - how to actually move your private repositories from Github to Bitbucket!

Import from Github to Bitbucket

  1. In Bitbucket on the top menu, click Repositories and then Import Repository Fields for importing existing code from Github
  2. Select Git
  3. Select 'Require Authentication'. Add the username and password from your github account. Note: You will get an authentication denied error anyway, which you can ignore.
  4. Copy the URL from your Github account. This should be This can be found in the right hand column under HTTPS URL of repository on Github
  5. Add the URL you copied in step 4 to URL field in Bitbucket
  6. The fields under New repository will be automatically filled in, including the Name. If you want to change the name and add a description, you can do so here. Fields for the new repository in Bitbucket
  7. Click import repository.

Change the origin URL

  1. Go to the repository on your local machine on the command line
  2. Type: git remote -v. This should show that the repo origin is still on github. E.g.
    origin (fetch)
    origin (push)
  3. Edit the git config file for the repository: sudo nano .git/config
  4. Change url (under remote "origin") and change to You may need to change the username if your username is different on bitbucket. You should also change it to the git URL. i.e.

Delete Github repository

Once you are happy that everything is working correctly with Bitbucket, it is time to delete the repository from Github.

  1. Go to the repo
  2. Go to settings Link to Github repository settings
  3. Under the Danger zone tab, click delete this repo

Downgrade your plan

Now that you have your repository safely on Bitbucket, and you have it deleted from Github, it is time to save some money and downgrade your Github plan to the free one.

  1. Go to settings for your account. Go to billing tab. Click on change plan tab. Downgrade to free account.


Repeat for all of your private repos.

That is all there is to it! If you have never used Bitbucket before, it is a good idea to do this for one repository first and ensure you are happy with Bitbucket before you switch everything over.


Great stuff, thanks for this guide

Thanks for the guide. Worked like a charm!

Great. Thank you so much!

Note that if you have two-factor authentication enabled you'll need to temporarily disable it for the import to work.

Blair Wadman's picture

Thanks for spotting that Jonathan, I'll update the post.

Near the end you say "You should also change it to the git URL. i.e.".

I'm new to the idea of a 'git url'. So naturally I have a few questions.

1: The 'git' url can be found on bitbucket's Overview screen and would look something like this for me:

...correct? Or would it start with 'git@' instead of 'darryn-smith@'?

2: If I choose not to put this in my git config file and instead go with the url format as it exists there:
(currently etc. and so on)

... will everything continue to work for a while as I read up on these fancy, new-fangled git-urls that are all the rage with you young whippersnappers?

Thanks for your time, and no matter what else happens, thank you for this guide. Very much appreciated.

Excellent! one more quesiton:
if I regularly push code to GitHub, how do I re-sync BitBucket with the previously imported repo ?

I have the same question which the previous commenter has posted. Any answer would be appreciated?

"if I regularly push code to GitHub, how do I re-sync BitBucket with the previously imported repo ?"

Blair Wadman's picture

Hi Jack and angelo,

You can add both Github and Bitbucket as remote repositories and push to both. There is some info here to get you started

I would recommend that if you are permanently moving your repositories off of one provider, you use the following command after cloning the target repository and setting the new remote URL:

$ git push --mirror;

This will ensure all artifacts are migrated (e.g. branches) rather than just currently active branch.

What about moving public github repos from github to bitbucket to make them private as you do not have money to pay for making it private on github?

Blair Wadman's picture

I'm pretty sure it would be the same process except make the repo in bitbucket - it shouldn't matter that the repo you are moving from on github is public.

Thanks for the article! It is great to know that there are possibilities to maintain private repositories for free.
I used Github with Student ticket (my sisters ID :) but it got expired, so all my private repositories went into disabled state.
Best regards

great article, thank you

Thanks for the article.
Can we achive the same with bitbucket remote api? If yes then how?

New comments for this tutorial have been turned off.