Last Updated: December 14, 2016
·
16.21K
· prudnikov

How to move GIT repo from one server to another

Here is how to move your GIT repository from one server to another. In my case I needed to move from GitHub to a private server.

git clone --bare git@github.com:{USERNAME}/{REPOSITORY_NAME}.git
cd {REPOSITORY_NAME}.git
git push --mirror git@myhost.com:my-new-repo.git
cd ..
rm -rf {REPOSITORY_NAME}.git

Now you have to change remote URL

git remote set-url origin git@myhost.com:my-new-repo.git

I'd recommend you to use Gitosis for private GIT management.