Leo's Technical Blog

Moving all your Bitbucket Repositories to GitHub

Introduction

user

Leo Soto


Moving all your Bitbucket Repositories to GitHub

Posted by Leo Soto on .
Featured

Moving all your Bitbucket Repositories to GitHub

Posted by Leo Soto on .

Last month at Continuum we moved from Bitbucket to GitHub. Since May 2016 GitHub's pricing model is reasonable for consultancies like us and after a while we decided to make the move.

Some of the moving process was manual (for active projects where team members were the best to judge when and what to migrate), I automated the rest of the process. Here is a little script that will move all the repositories from your organization in BitBucket as private repositories in your GitHub organization:

You'll need to install bitbucket-cli first. Then, just export the environment variables needed by the script and run it. For example, in my case it was:

$ export GH_USERNAME=leosoto
$ export GH_PASSWORD=heregoesyourpassword
$ export GH_ORGANIZATION=continuum
$ export BB_USERNAME=leosoto
$ export BB_PASSWORD=heregoesyourotherpassword
$ export BB_ORGANIZATION=continuumchile
$ ./bb2gh.sh

That is: Move all repositories from bitbucket.org/continuumchile to github.com/continuum, using leosoto's credentials to make the move (which has to be a member of the respective organizations). The script assumes you have the right ssh keys to pull from bitbucket and push to github.

And after a couple of hours, it migrated all our repositories (except one which had files too large for GitHub which we had to migrate by hand).

WARNING: Repositories that are successfully upload to GitHub will be removed from BitBucket by the script itself. If you don't want that, you should edit the script to suit your needs.

Also remember to remove the sensitive passwords from your shell history after running the script.