Question

Can a git repository be copied between servers?

In my situation, I'm migrating to a different server, and in a perfect world I could simply secure copy the git directory to the new server form the old server. I am not totally sure if a git repository is machine dependent.

Would any issues arise if I simply copied the repo rather than reinitializing it?

I understand that it's not terribly difficult to git init assuming everything is checked in, but for reasons that are not worth explaining, lets just assume it would save me a lot of trouble to simply copy the directory.

Était-ce utile?

La solution

Can a git repository be copied between servers?

Yes, it can be copied without a problem.

Would any issues arise if I simply copied the repo rather than reinitializing it?

No, but of course you can always try it to be sure.


My recommendation on the other hand would be to do it more properly. On your new server do a git init --bare and from your old repository push everything to the new server and let git handle all the copy (which is also compressed by the way, so it's faster).

A summary would be:

# on new server:
$ mkdir repo && cd repo && git init --bare

# on old server:
$ cd repo
$ git remote add new_server path/to/new/server
$ git push new_server --mirror

Note that --mirror makes the new server a mirror of this server, which means it pushes all the branches, tags, etc.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top