Categories: Just Sayin'

How to migrate private repository from BitBucket to GitHub

Last year Microsoft bought GitHub for $7.5B and shortly after that they have changed their policy on private repositories. Before, private repositories were reserved only for paying members, but since January 7th 2019 even non-paying users are allowed to have unlimited private repositories.

In case you want to migrate your private repository from BitBucket to GitHub and keep all the previous gits.

First, login to your GitHub and make a new empty private repository (do not tick “Initialize this repository with a README”). You can use any name but the best practice is to use the same name as on BitBucket.

Now let’s clone the repository from BitBucket and push it back to GitHub. Make sure to replace geektnt with your bitbucket/github username and coolproject with an actual repository name.

git clone --mirror https://bitbucket.org/geektnt/coolproject.git
cd coolproject.git
git remote set-url --push origin git@github.com:geektnt/coolproject.git
git push --mirror

After this is done you can leave the folder and remove the repository directory (since it’s not usable project as it’s cloned with –mirror parameter)

cd ..
rm -rf coolproject.git

And you can now clone it from GitHub and continue where you have stoped:

git clone git@github.com:geektnt/coolproject.git
cd coolproject
...
(make changes, add, commit, push...)

At this point you can remove old BitBucket repository if everything works at GitHub.

This way to migrate worked out amazing for me and I have moved couple of my older private projects from BitBucket to GitHub so I can have them all at one place.

Share
Published by
Nick

Recent Posts

How to Manage Storage on Smartphone: 12 Ways

Can't download new apps to your phone because there isn't enough storage space? Lack of…

10 months ago

Spotlight Search won’t open the files it finds in Dropbox with associated application

This issue started to appear on macOS 13 Ventura after recent Dropbox update. I would…

1 year ago

Windows 10 Search fix

Since this morning (Feb 5th 2020) search just stopped working on my Windows 10 (version…

4 years ago

The mysql_result in mysqli

Many of you have run into a problem when you were working on some old…

4 years ago

How to convert physical Windows PC into a virtual machine

After 10 years of running my main desktop computer on Windows 7 - time has…

4 years ago

How to downgrade PHP 7.4 to PHP 7.3 on VestaCP running on CentOS 7

I installed VestaCP for a clien on a new dedicated server running CentOS 7. Once…

4 years ago