Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 6 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

This is a more unusual use case, but...

I've seen the repo utility make symbolic links in the .git directory. In that case, when you're doing a copy, you'd want to make sure you dereference symbolic links. E.g.:

cp -r -L <source-repo-dir> <destination-repo-dir>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.