Created
October 6, 2020 10:33
-
-
Save iamcryptoki/9b4022417337a418ba514478dbdde0e8 to your computer and use it in GitHub Desktop.
Migrate Git repository with history and branches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Clone current repo. | |
| $ git clone https://current.example.com/repo.git | |
| $ git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done | |
| $ git fetch --all | |
| $ git pull --all | |
| # Change Git remote's URL. | |
| $ git remote set-url origin https://new.example.com/repo.git | |
| $ git push --all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment