How to Migrate Code Between Git-Based Source Code Repositories

Guillermo Musumeci
3 min readMay 23


In this story, we will discuss how to migrate between Git-Based Source Code Repositories, such as Bitbucket, Azure DevOps, GitHub, GitLab, and any Git-based source code repository.

Migrating Git Code Repositories

Here is the procedure to migrate repos between any Git-based source code repositories:

  1. Optional step: Create the destination Git repo if it does not exist.
  2. Optional step: Install the git tools (if not installed) on your computer from
  3. Open the command line or console on your computer.
  4. Authenticate to both Git-based source and destination code repositories.
  5. Change to a temp folder used to store the content of the source Git repo and execute the following code:
git clone --mirror <source_git_repo_address>

6. Change to the repo folder created (ended in .git) and then type the following command to remove the remote origin from the Git Repository:

git remote rm origin

7. After that, we add the destination repository as the origin with the following command:

git remote add origin <destination_gt_repo_address>

8. Finally, we push the code to the destination Git repo with the following command:

git push --mirror


git push origin --all
git push --tags

Example of Migrating Git Code Repositories

Here is an example of a migration from Azure DevOps to GitHub using the procedure above:

D:\> cd d:\migration

D:\migration> git clone --mirror

Cloning into bare repository 'terraform-kopicloud-ad-api-adgroup.git'...
remote: Azure Repos
remote: Found 86 objects to send. (107 ms)
Unpacking objects: 100% (86/86), 14.98 KiB | 1024 bytes/s, done.

D:\migration> cd D:\migration\terraform-kopicloud-ad-api-adgroup.git

D:\migration\terraform-kopicloud-ad-api-adgroup.git> git remote rm origin
Note: Some branches outside the…



Guillermo Musumeci

Certified AWS, Azure & GCP Architect | HashiCorp Ambassador | Terraform SME | KopiCloud Founder | ex-AWS | Entrepreneur | Book Author | Husband & Dad of ✌