We are using Git for our project. Repository is rather huge (the .git folder is about 8Gb).
We are using git checkout -f in post-receive hook to update working tree.
The problem is that checking out of even a couple of slightly changed files takes too long, approximately 20 seconds. I’ve no idea why is it so long.
Can be that the problem of the repository size?
What steps or tools should I try to locate and investigate the problem further?
Thank you for any help.
Regards,
Alex
Original answer (Nov 2012)
I confirm git will slow down considerably if you keep a git directory (
.git) that large.You can see an illustration in this thread (not because of large files, but because of large number of files and commit history):
At the very least, you could consider splitting the repo, isolating the binaries in their own git repo and using submodules to keep track between the source and binary repositories.
It is best to store large binary files (especially if they are generated) outside of a source referential.
An "artifact" repository is recommended, like Nexus.
All-git solution to appear keeping those binaries are git-annex or git-media, as presented in "How to handle a large git repository?".
Update February 2016: git 2.8 (March 2016) should improve somewhat significantly the
git checkoutperformance.See commit a672095 (22 Jan 2016), and commit d9c2bd5 (21 Dec 2015) by David Turner (
dturner-tw).(Merged by Junio C Hamano —
gitster— in commit 201155c, 03 Feb 2016)Using sparse-checkout, a checkout of a huge repository can be considerably speed up.
And that improved even more with Git 2.33 (Q3 2021), where "
git checkout"(man) andgit commit(man) learned to work without unnecessarily expanding sparse indexes.See commit e05cdb1, commit 70569fa (20 Jul 2021), and commit 1ba5f45, commit f934f1b, commit daa1ace, commit 11042ab, commit 0d53d19 (29 Jun 2021) by Derrick Stolee (
derrickstolee).(Merged by Junio C Hamano —
gitster— in commit 506d2a3, 04 Aug 2021)