When it comes to Bitbucket and GitHub, each offers their advantages and disadvantages. I’ve used them both and like them each for different reasons.

Migrating From Bitbucket to GitHub: Bitbucket

But I prefer GitHub for a few more reasons than Bitbucket (the least of which is not that my organization was hosted there). And I like to have everything, more or less, under the same service.

Migrating From Bitbucket to GitHub: GitHub

I’ve spent some time over the past week migrating from Bitbucket to GitHub. I currently maintain two personal accounts:

  • one for myself,
  • one for Pressware.

I’ve opted to downgrade my organization account to a personal account to save money and because I’m more or a less a company of one who occasionally has collaborators.

Various guides online leave something to be desired when it comes to walking through how to go about migrating from Bitbucket to Github, so I thought I’d share my experience for doing that.

Migrating From Bitbucket to GitHub

First, in writing this, I’m assuming that you want to maintain two personal accounts each of which has their own GitHub account and thus their email address.

If that’s the case, then this should provide you with everything to need. I’m also assuming that you have two accounts set up – nothing moe (that is, no SSH keys or anything of the like).

In my examples, I’m using pressware as the username. You’ll need to replace this with whatever you like.

With that said, here’s what you need to do.

1. Generate an SSH Key

First, you’re going to need to generate an SSH key. Depending on the type of work you do, you may want to be careful with this. That is, if you have an existing id_rsa file, don’t overwrite it. Instead, we’ll create a second one.

To do this, open a terminal and enter the following replacing the specified email address with the email address of the second account that you’ve created (in my case, this is my pressware account as opposed to my tommcfarlin account).

When it asks for the name of the file you want to use, suffix it with the username (or name it anything you like – I just happen to be a fan of doing it this way).

In my case, I’m saving the file to id_rsa_pressware.  Next, specify whatever passphrase you’d like.

2. Add the Key to Your Local Agent

Next, you’re going to need to add the key to your SSH agent. All of this is necessary to we can communicate with the proper GitHub account when it comes time to start migrating from Bitbucket to GitHub.

To do this, enter the following command in your terminal:

This will start the ssh-agent program as a background process. After that, enter the next command:

This will add the SSH private key and store the passphrase in your operating systems keychain.

3. Add the SSH Key to GitHub

Next, login to the GitHub account to which you’ll be migrating the repositories. In the account, click on your profile icon then click on the Settings menu item.

Migrating From Bitbucket to GitHub

From there, choose the option for SSH and GPG Keys. After that, copy the contents of the newly created key to your clipboard. You can do this in the terminal with the following command:

Next, click on the New SSH Key button and, on the following page, give the key whatever name you’d like and paste the contents that were just copied to your keyboard.

4. Migrate Your Repositories

To keep things succinct, I’m going to show how to copy a single repository from. Bitbucket but you’ll need to do this for as many repositories as you have to migrate.

First, on GitHub, create an empty repository with the same name as the one you’re going to be migrating. In the example below, I’ll simply use acme-repository.

Next, enter the following command in your terminal:

This will clone a mirror of the acme-repository to your Desktop. After that, navigate inside of the directory (by entering cd acme-repository.git).

Next, enter this command in your terminal:

This will set a new upstream remote URL to which all of the repository contents should be pushed.

After you’ve done that, it’s a matter of pushing the contents of the repository:

Depending on the size of the repository, this may take a little bit of time, but the work is done.

And That’s It

It would be easy to say “that’s all!” but it’s a bit of time-consuming work if you have multiple repositories, aren’t familiar with SSH, or are new to this whole thing.

But once everything is set up and organized, it’s much nicer to have everything on the same service if only separate by accounts.

Finally, at the time of this writing, this is how I was migrating from Bitbucket to GitHub. Like other posts and articles online, this could easily be out of date within a few months.

I’ll do what I can do to keep it current. If you notice it’s out of date, don’t hesitate to let me know.