The quick, easy and complete way:
-
Clone the repo you want to move or skip this step if you already have one set up:
git clone git@oldreposerver:repo/name <insert dir> cd <insert dir>
-
Make sure your repo has all the latest news from its current
origin
:git fetch --all
-
Add the new
origin
as a temporary remote whilst keeping the old one for now:git remote add newrepo ssh://git@newreposerver:newrepo/newname
-
Push all
refs
fromorigin
to their equivalent counterpart onnewrepo
:git push newrepo '+refs/remotes/origin/*:refs/heads/*'
-
Switch
origin
around so your new repository becomes default:git remote rename origin oldrepo git remote rename newrepo origin
-
Or get rid of the old
origin
altogether if you’re positive you won’t be needing it anymore:git remote remove origin git remote rename newrepo origin