Is it OK to copy (not clone) a git repository using basic Unix commands?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Horror Game Menu Looping
--
Chapters
00:00 Is It Ok To Copy (Not Clone) A Git Repository Using Basic Unix Commands?
00:45 Accepted Answer Score 26
01:12 Answer 2 Score 2
01:29 Answer 3 Score 1
01:50 Answer 4 Score 0
02:32 Thank you
--
Full question
https://superuser.com/questions/315398/i...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#git #tar
#avk47
ACCEPTED ANSWER
Score 26
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.
ANSWER 2
Score 2
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.
ANSWER 3
Score 1
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>
ANSWER 4
Score 1
It is OK but if you are about to share your repo with someone else, please consider the following:
- Your
config
file might have remotes the other person might not care. - Your
logs
folder will have references that you might not want to share. Git is great at letting you do the nasty stuff on your computer until you are comfortable with the final result, and then push it to the remote to (occasionally) share it. Some of that nasty history might be in your reflog, so it is better to not share it IMHO. - Your
info/exclude
file might be ignoring some files only you want to ignore. - You can also have hooks, branches, and a bunch of other stuff which is personal and you prefer to not share...