应该多久使用一次git-gc?
手册页简单地写着:
鼓励用户在每个存储库中定期运行此任务,以保持良好的磁盘空间利用率和良好的操作性能。
是否有一些命令来获取一些对象计数,以确定是否到了gc的时候?
应该多久使用一次git-gc?
手册页简单地写着:
鼓励用户在每个存储库中定期运行此任务,以保持良好的磁盘空间利用率和良好的操作性能。
是否有一些命令来获取一些对象计数,以确定是否到了gc的时候?
当前回答
你可以在没有任何中断的情况下,使用新的(Git 2.0 Q2 2014)设置gc.autodetach。
参见commit 4c4ac4d和commit 9f673f9 (nguyshape Thái ngeconc Duy, aka pclouds):
Gc—auto需要时间,并且可以暂时阻止用户(但也不那么烦人)。 让它在支持它的系统后台运行。 在后台运行唯一丢失的是打印输出。但是gc输出并不是很有趣。 你可以通过修改gc.autodetach来保持它在前台。
从2.0版本开始,就有一个bug: git 2.7(2015年Q4)将确保不会丢失错误消息。 参见commit 329e6e8 (19 Sep 2015) by nguyThái ngeconc Duy (pclouds)。 (由Junio C Hamano合并- gitster -在commit 076c827, 2015年10月15日)
gc: save log from daemonized gc --auto and print it next time While commit 9f673f9 (gc: config option for running --auto in background - 2014-02-08) helps reduce some complaints about 'gc --auto' hogging the terminal, it creates another set of problems. The latest in this set is, as the result of daemonizing, stderr is closed and all warnings are lost. This warning at the end of cmd_gc() is particularly important because it tells the user how to avoid "gc --auto" running repeatedly. Because stderr is closed, the user does not know, naturally they complain about 'gc --auto' wasting CPU. Daemonized gc now saves stderr to $GIT_DIR/gc.log. Following gc --auto will not run and gc.log printed out until the user removes gc.log.
其他回答
如果你在使用Git-Gui,它会告诉你什么时候应该担心:
这个存储库目前大约有1500个松散对象。
下面的命令会得到一个类似的数字:
$ git count-objects
除了,从它的源代码,git-gui将自己进行数学计算,实际上在.git/objects文件夹中计算一些东西,并可能带来一个近似值(我不知道tcl能正确读取它!)
无论如何,它给出的警告似乎是基于大约300个松散物体的任意数字。
最新版本的git在需要时自动运行gc,所以你不需要做任何事情。参见man git-gc(1)的Options部分:“一些git命令在执行可能创建许多松散对象的操作后运行git gc——auto。”
我使用git gc后,我做了一个大的签出,并有很多新对象。它可以节省空间。例如,如果您使用git- SVN签出一个大型SVN项目,并执行git gc,通常可以节省大量空间
你不需要经常使用git gc,因为git gc(垃圾收集)在几个常用的命令上自动运行:
git pull
git merge
git rebase
git commit
来源:git gc最佳实践和常见问题解答
你可以在没有任何中断的情况下,使用新的(Git 2.0 Q2 2014)设置gc.autodetach。
参见commit 4c4ac4d和commit 9f673f9 (nguyshape Thái ngeconc Duy, aka pclouds):
Gc—auto需要时间,并且可以暂时阻止用户(但也不那么烦人)。 让它在支持它的系统后台运行。 在后台运行唯一丢失的是打印输出。但是gc输出并不是很有趣。 你可以通过修改gc.autodetach来保持它在前台。
从2.0版本开始,就有一个bug: git 2.7(2015年Q4)将确保不会丢失错误消息。 参见commit 329e6e8 (19 Sep 2015) by nguyThái ngeconc Duy (pclouds)。 (由Junio C Hamano合并- gitster -在commit 076c827, 2015年10月15日)
gc: save log from daemonized gc --auto and print it next time While commit 9f673f9 (gc: config option for running --auto in background - 2014-02-08) helps reduce some complaints about 'gc --auto' hogging the terminal, it creates another set of problems. The latest in this set is, as the result of daemonizing, stderr is closed and all warnings are lost. This warning at the end of cmd_gc() is particularly important because it tells the user how to avoid "gc --auto" running repeatedly. Because stderr is closed, the user does not know, naturally they complain about 'gc --auto' wasting CPU. Daemonized gc now saves stderr to $GIT_DIR/gc.log. Following gc --auto will not run and gc.log printed out until the user removes gc.log.