kyk's blog

Git Move Repo

  1. Clone the project from old repo url

    git clone <old_repo_url>
    
  2. Pull all branches

    git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
    git fetch --all
    git pull --all
    
  3. Change remote to new repo url

    git remote set-url origin <new_repo>
    
  4. Push all to new repo url

    git push --all
    git push --tags