如何防止 GIT 中的垃圾收集? [英] How to Prevent Garbage Collection in GIT?
问题描述
Git 会不时"神秘地运行垃圾收集并删除和孤立您拥有的提交.
Git mysteriously runs Garbage collection "from time to time" and deletes and orphaned commits you have.
https://www.kernel.org/pub/software/scm/git/docs/git-gc.html
从科学上讲,这大约会在您意识到自己真正需要刚刚删除的提交之前发生大约 6-8 小时.
Scientifically, this will occur approximately 6-8 hours before you realize you really needed that commit which was just deleted.
我不希望我的文件被 Git 删除.如何完全禁用自动垃圾收集?
I'd rather not have my files deleted by Git. How can I disable automatic garbage collection altogether?
推荐答案
来自 与您刚刚链接到的页面完全相同:
某些 git 命令可能会自动运行 git gc;有关详细信息,请参阅下面的 --auto 标志.如果您知道自己在做什么,并且只想永久禁用此行为而无需进一步考虑,请执行以下操作:
Some git commands may automatically run git gc; see the --auto flag below for details. If you know what you’re doing and all you want is to disable this behavior permanently without further considerations, just do:
$ git config --global gc.auto 0
这篇关于如何防止 GIT 中的垃圾收集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!