3 ms·
How is git clone faster than `cp -r`?
by voltagex_ 8y ago
How is git clone faster than `cp -r`?
- dleslie 8y agoIt may be in relation to when you duplicate a repository. When you cp an active git repository you receive an identical file state; when you git clone you receive only what is necessary. Old objects, reflogs, et al aren't in the clone. A clone of an existing local repository may also make hard links, if your file system supports it.
- simcop2387 8y agoMy first guess would be that git is going to be faster since it won't be doing a huge number of stat() calls and similar to grab metadata about the files it's creating, instead git will have the data in a single data structure it can efficiently ask for it from. Of course the filesystem has this too, but git will have it in a single location and probably more compactly, leaving it able to do it all with fewer reads. Then it has the data in the files compressed so the read is faster too. All this should mean that git can get to writing the files faster than cp will.
- LukeShu 8y agohttp://gitolite.com/git-performance.html http://gitolite.com/git-performance.html (the obvious answer) https://apenwarr.ca/log/20080121 https://apenwarr.ca/log/20080121 (some more nuance)