How to Migrate Code Between Git-Based Source Code Repositories

Guillermo Musumeci
3 min readMay 23, 2023

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 https://git-scm.com/downloads/guis.
  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…

--

--

Guillermo Musumeci

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