Reputation: 75376
We have a git repository which is rather large but which has rather few files actually present in the workspace. Due to its size and our draconian anti-virus settings it takes quite a while to clone, which makes it more tedious to work with a lot of small branches (as Eclipse gets very confused when git manipulates the maven projects in the workspace).
Hence I would like to have a faster way to create a new git checkout "next" to an existing clone in the file system (but completely independent from it) at the exact same branch and commit as the existing clone, and I wondered if I could simply make a plain copy of the folder containing .git
and continue working in the two projects independently.
(Also I remembered seing something about git cloning on a local file system and saving space with hardlinks. This is not important but may be nice if it works on Windows.)
So, can I simply copy an existing git workspace (including .git) to get the same result as a new git clone
?
Upvotes: 4
Views: 530
Reputation: 382160
Yes, you can copy or move a git directory. There is nothing preventing it.
If you use another user, or want to use different remote repositories, you might want to change what's inside the .git/config
file after that but that's all.
This being said, I don't see why copying the repository would be faster than cloning it locally. It should be the reverse as the work directory can be recreated from the .git
directory (if you copy just this directory, simply do git reset --hard
after).
Upvotes: 7