Git clone is slow - can I just copy an existing clone to a new directory?

We have a git repository which is quite large but has quite a few files actually present in the workspace. Due to its size and our draconian antivirus settings, it takes quite a long time to clone, making it more tedious to work with many small branches (as Eclipse gets very confusing when git manages maven projects in the workspace).

Hence, I would like to have a faster way to create a new git checkout "next" with an existing clone on the filesystem (but completely independent of it) on the same branch and commit as an existing clone, and I wondered if I could just do a regular copy of the folder containing .git

, and continue working in the two projects independently.

(Also I remembered how something meaningful about git cloning on the local filesystem and saving hard link space. It doesn't matter, but it might be fine if it works on Windows.)

So, can I just copy the existing git workspace (including .git) to get the same output as the new one git clone

?

+3


source to share


1 answer


Yes, you can copy or move the git directory. Nothing bothers him.

If you are using a different user or want to use different remote repos, you may need to change what is inside the file .git/config

after that, but that's it.



That being said, I don't understand why copying a repository would be faster than cloning it locally. It should be the other way around, since the working directory can be recreated from the directory .git

(if you only copy that directory, just do git reset --hard

after).

+5


source







All Articles