Moving or relocating a git repository to a new server

If you or your company decides to move git repository to a new server location, here is quick commands that you would need to move or relocate your source code repository.

// create a new origin named new-origin and point it to new server
git remote add new-origin  // ex: git@github.com:manakor/manascope.git
// push all code and tags to new origin
git push --all new-origin
git push --tags new-origin
// remove old origin and rename new origin to make it default. This will enable all new commits to go to new server
git remote rm origin
git remote rename new-origin origin

If these commands helped you, don’t forgot to leave a comment.

Source: Smashing Magazine

Leave a Reply

Your email address will not be published. Required fields are marked *