Moving repo to new repo with all branches and tags

Sometimes there is need to set up repo at new hoster and move existing repo to this new repo and keep all history, all branches and all tags. Here is the recipe how to do it.

git clone --mirror <old repo> temp-dir
cd temp-dir
git tag
git branch -a
git remote rm origin
git remote add origin <new repo>
git push --all origin
git push --tags origin

 

Leave a Comment.