Back to Blog
May 3, 2026

Github - Bit bucket mirroring

repo swapping github gitlab code version control

GitHub to Bitbucket Mirroring (With Commit History & Sync).

Requirement.

In some environments, projects are actively developed and deployed using GitHub, but there is also a need to maintain a synchronized copy in Bitbucket. The goal is to: Mirror the repository from GitHub to Bitbucket Preserve full commit history Keep both repositories in sync for continuous deployment

Step-by-Step Implementation.

Clone the GitHub Repository.

Terminal
$ git clone git@github.com:<github_user_name>/<github_repo_name>.git cd <github_repo_name>

Rename Default Remote.

Terminal
$ git remote rename origin github

Add Bitbucket as a Remote.

Terminal
$ git remote add bit <bitbucket_repo_url>

Fetch Bitbucket Data.

Terminal
$ Fetch Bitbucket Data

Checkout Bitbucket Branch.

Terminal
$ git checkout -b bit-branch bit/<branch_name>

Merge GitHub into Bitbucket.

If both repositories were created independently, Git may treat them as unrelated histories. Resolve any merge conflicts if prompted.

Terminal
$ git merge github/<branch_name> --allow-unrelated-histories

Push to Bitbucket.

Terminal
$ git push bit <branch_name>

Keeping Repositories in Sync.

Terminal
$ git pull github <branch_name> git push bit <branch_name>

# References