Migrate Git repository from Bitbucket to GitHub


Hey 👋, recently I wanted to play with GitHub Actions and this blog (upcoming post 👀) and I realised that I had this repository still in Bitbucket.

So I decided to migrate the Git repository from Bitbucket to GitHub.

Here’s what I needed to do:

  1. Made a fresh new clone of my Bitbucket repository to a new localtion
git clone --mirror <bitbucket-repository>
  1. Removed the origin remote, so that we can set the new one from GitHub.
git remote rm origin
  1. Went to GitHub and created the new repository (a private repository in my case).
  2. Added the new origin remote from GitHub.
git remote add origin <github-repository>
  1. Push everything to GitHub’s remote.
git push --mirror origin
  1. Now, I went and ‘cloned’ the new GitHub repository to confirm everything was fine.
git clone <github-repository>
  1. After confirming the new cloned repository has everything I removed the one we used for migration.

Some extra notes:

Was this helpful to make the switch to GitHub? Let me know by clicking on the 👍 button below!