3

A while ago we setup a git repository for internal use on a local server. The server is not on a business line and thus has a non-static ip.

We want to move the git origin from the local server to a new remote server (this is our private dedicated server, not github or similar).

Can we just rsync the entire git directory over to the new server?

3 Answers3

3

Though the simplest way would surely be to do a git clone, yes, you can use rsync.

gturri
  • 13,807
  • 9
  • 40
  • 57
  • If it's a bare repository you're moving (ie. what people push to and pull from with no checkout) with clone you'll want `git clone --bare` and probably `--mirror`. – Schwern Jan 25 '15 at 17:36
2

The safest way (which would not bring with it local config or hooks, which can be specific to the local environment, and have sensitive information you wouldn't always want to include in an archive) would be to use git bundle.

git bundle create /tmp/myrepo.bundle --all

See "How can I email someone a git repository?"

That creates only one file (easy to copy around), which you can clone or fetch from:
On the target server

git clone myrepo.bundle
cd myrepo
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

Git repositories have nothing linking them to their directory or server (unless you configured something specifically). You can move them like any other directory of files. A USB stick, scp, rsync, mv, zip, tar... whatever.

Schwern
  • 153,029
  • 25
  • 195
  • 336
  • Yea i just rsync'd the whole thing over then did a clone of the new repo from the remote server to my local machine.. working perfectly. Couldn't believe it could be that simple.. thanks :) –  Jan 25 '15 at 17:37