Is it OK to copy (not clone) a git repository using basic Unix commands?

I’m pretty new to using git and was wondering if it’s ok to copy a Git repository with common UNIX commands (like cp or tar/untag), rather than through git clone.

I’m in the situation where I have a production environment (python virtual) that some code checked out in git in it. I’m wondering if it's a bad idea from a git perspective to copy down the whole environment using a tar or something. This approach would be convenient for making a quick copy of a codebase/environment.

My concern is that maybe git clone associates some unique id with the working copy that could cause conflicts if two working copies exist where one was filesystem-copied from the other.


It is perfectly fine.

git stores all of its history, commits, etc. on site - this is a fundamental property of a DCVS.

Technically speaking, git can operate just fine with copied repositories running around everywhere, because the whole point of a DCVS is that it doesn't have to know what's going on outside of any given repository, and in fact doesn't unless you tell it.

The same principle applies here.


You should be able to copy the entire working directory to anywhere else on your system and have it continue to function as normal when using Git, Hg, or SVN. I can't comment on other SCMs.