Migrating a repository from Bitbucket to GitHub

Somebody who likes to code
Search for a command to run...

Somebody who likes to code
No comments yet. Be the first to comment.
Google processes tens of thousands of code changes every day across a codebase of hundreds of millions of lines. The secret isn't magic tooling — it's a documented, principled approach to code review

Amazon Simple Notification Service (SNS) looks straightforward on the surface — publish a message, deliver it to subscribers — but the gap between a topic that "works in dev" and one that is productio

Amazon Simple Queue Service (SQS) is deceptively simple to get started with, but surprisingly easy to misconfigure in ways that cause silent message loss, runaway costs, duplicate processing storms, o

HTTP API is the right default choice for the majority of .NET serverless workloads. At 70% less cost than REST API, lower latency, and native JWT authorization, it covers most production requirements

AWS Lambda has become a cornerstone of modern serverless architectures, but writing a function that "just works" is very different from writing one that is performant, cost-effective, secure, and read

Several years ago, we started using Bitbucket because it provided unlimited private repositories. But today, GitHub also offers the same plus useful tools and integrations. So, we started to migrate repositories from Bitbucket to Github.
Let's start by looking at the commit history (master branch) of the repository we want to migrate. Run git log --oneline --graph:
* 2849da4 (HEAD -> master, tag: 1.0.0, origin/master, origin/HEAD) Pull request #2: Update README.md
|\
| * f5ec292 (origin/release/1.0.0, release/1.0.0) Update README.md
|/
* ce82b26 Create README.md
And the remote branches with git branch -r:
origin/HEAD -> origin/master
origin/develop
origin/master
origin/release/1.0.0
The idea is to move everything to the new repository using the minimum number of git commands.
Create a new repository on GitHub. The repository needs to be empty, with no README file, no license file, and no .gitignore file:

Run git clone --bare https://raulnq@bitbucket.org/raulnq/old-repository.git:
Cloning into bare repository 'old-repository.git'...
remote: Enumerating objects: 8, done.
Receiving objects: 100% (8/8), done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 8 (delta 1), reused 0 (delta 0), pack-reused 0
Resolving deltas: 100% (1/1), done.
Run cd old-repository.git and git push --mirror https://github.com/raulnq/new-repository.git:
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 20 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (8/8), 834 bytes | 834.00 KiB/s, done.
Total 8 (delta 1), reused 8 (delta 1), pack-reused 0
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/raulnq/new-repository.git
* [new branch] develop -> develop
* [new branch] master -> master
* [new branch] release/1.0.0 -> release/1.0.0
* [new tag] 1.0.0 -> 1.0.0

And that's it. You can clone your new repository and start to work on it. Thank you, and happy coding.