Moving remote Git repository

Jul 11, 2014
It is surprising that most of the search results related to moving Git repository is targeted towards moving repositories to and alike. I was trying to move my git repository from, say, to These servers are Linux servers and are accessible via SSH. However, using the common set of instructions i.e. git clone --bare followed by git push --mirror kept throwing me following error: $ git push -v --mirror ssh:// Pushing to ssh:// fatal: '/home/user/Repo.git' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. Some posts suggested to first initialize a git repository on server. This sounded odd to me as per my understanding, all we need is SSH access to the server in order to setup as a remote Git repository.

And it turns out that the answer is very simple and is actually explained on Git documentation. Just perform a local --bare clone of the repository then scp or rsync it to server and update origin of the repository. Thats it! All push/pull would work as expected after that with new server. Here are steps I followed (notice server1 and server2 in the commands): # Check current remotes $ cd /home/user/Repo $ git remote -v origin (fetch) origin (push) # Temporary --bare clone in /tmp $ cd /tmp $ git clone --bare file:///home/user/Repo Cloning into bare repository 'Repo.git'... remote: Counting objects: 4389, done. remote: Compressing objects: 100% (4349/4349), done. remote: Total 4389 (delta 3138), reused 3 (delta 0) Receiving objects: 100% (4389/4389), 45.46 MiB | 15.28 MiB/s, done. Resolving deltas: 100% (3138/3138), done. Checking connectivity... done. # Transfer the new bare repository to new server using scp or rsync $ scp -r Repo.git # Update origin url in local repository $ cd /home/user/Repo $ git remote set-url origin # Check the updated remotes $ git remote -v origin (fetch) origin (push) # Delete the temporary clone in /tmp $ rm -rf /tmp/Repo.git
Read more ...