提高git状态表现的方法 [英] Ways to improve git status performance
问题描述
我在NFS上的Linux机器上有10 GB的回购。第一次 git status
需要36分钟,随后的 git status
需要8分钟。似乎Git依靠操作系统来缓存文件。只有第一个 git
命令像 commit
, status
打包/重新包装整个回购需要很长时间才能完成大回购。我不确定你是否在这么大的回购库上使用了 git status
,但是有谁遇到过这个问题?
我试过 git gc
, git clean
, git repack
但花费的时间仍然/几乎相同。
子模块或任何其他概念(如将分解库分成更小的分区都有帮助)?如果是的话,哪个最适合分拆更大的回购。有没有其他方法可以提高git命令在大型repo上花费的时间?
lstat(2)
系统调用的效率,所以调整你的客户端的attribute cache timeout可能会有所斩获。 git-update-index
- 本质上是 git-status
的手动模式 - 描述了你可以通过使用 - 承担 - 不变
标志以禁止其正常行为并手动更新已更改的路径。您甚至可以编程您的编辑器以在每次保存文件时取消设置此标志。
另外,如您所示,可以减少您的结帐尺寸(尺寸的包装文件在这里并不真正起作用)。这些选项是稀疏结帐,子模块或Google的回购工具。
(有一个邮件列表有关使用Git与NFS ,但它没有回答很多问题。)
I have a repo of 10 GB on a Linux machine which is on NFS. The first time git status
takes 36 minutes and subsequent git status
takes 8 minutes. Seems Git depends on the OS for caching files. Only the first git
commands like commit
, status
that involves pack/repack the whole repo takes a very long time for a huge repo. I am not sure if you have used git status
on such a large repo, but has anyone come across this issue?
I have tried git gc
, git clean
, git repack
but the time taken is still/almost the same.
Will sub-modules or any other concepts like breaking the repo into smaller ones help? If so which is the best for splitting a larger repo. Is there any other way to improve time taken for git commands on a large repo?
To be more precise, git depends on the efficiency of the lstat(2)
system call, so tweaking your client’s "attribute cache timeout" might do the trick.
The manual for git-update-index
— essentially a manual mode for git-status
— describes what you can do to alleviate this, by using the --assume-unchanged
flag to suppress its normal behavior and manually update the paths that you have changed. You might even program your editor to unset this flag every time you save a file.
The alternative, as you suggest, is to reduce the size of your checkout (the size of the packfiles doesn’t really come into play here). The options are a sparse checkout, submodules, or Google’s repo tool.
(There’s a mailing list thread about using Git with NFS, but it doesn’t answer many questions.)
这篇关于提高git状态表现的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!