Contents

Git Repository Migration Guide: How to Elegantly Change Remote Repository Address

Git Repository Migration to New Remote Repository Address Guide

Moving a repository to a new remote address is as simple as adding a new remote and pushing. Here are the detailed operation steps.

Step Instructions

Just like moving household items to a new house, first tell Git the new address, then move all the content.

1. Add New Remote Repository

Using new-origin as an example, execute:

git remote add new-origin new-repository-address

2. Push All Branches

Note: The parameter uses two dashes --, not Chinese long dashes.

git push new-origin --all

3. Push All Tags

git push new-origin --tags

4. (Optional) Set New Remote as Default

If you only want to use the new repository in the future, you can change origin to the new address:

git remote remove origin
git remote rename new-origin origin

Summary

Through the above steps, all content (branches, tags) from the original repository will be synchronized to the new repository. This is suitable for scenarios like project migration, backup, or changing remote platforms.