1 minute read

Problem: You want to switch the repo from a server where you don't have root access to another where you do.

Copying from local machine to the new server (source)

# on new server:
$ mkdir ~/repoName && cd ~/repoName && git init --bare

# on local machine:
$ git remote set-url origin myServer.io:repoName
$ git push --mirror

You might get the following warning when cloning

# on local machine:
$ cd /tmp
$ git clone myServer.io:repoName
<truncated>
warning: remote HEAD refers to nonexistent ref, unable to checkout.

Then you need to switch HEAD variable on new server (source)

# on new server:
$ cd ~/repoName
$ git symbolic-ref HEAD refs/heads/main

Categories:

Updated: