Skip to content

Instantly share code, notes, and snippets.

@iamcryptoki
Created October 6, 2020 10:33
Show Gist options
  • Select an option

  • Save iamcryptoki/9b4022417337a418ba514478dbdde0e8 to your computer and use it in GitHub Desktop.

Select an option

Save iamcryptoki/9b4022417337a418ba514478dbdde0e8 to your computer and use it in GitHub Desktop.
Migrate Git repository with history and branches.
# 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