How do I fix these Git GC problems?

ε祈祈猫儿з 提交于 2019-12-05 17:41:21

The only real way around it is to reduce the size of your repository. You can disable automatic garbage collection with git config --global gc.auto 0, but that will increase your network traffic on pushes and pulls, if they even still work at all, and will increase your local disk space used for git. Without git gc, your local repo will contain a full copy of every revision of every file you change. However, that might be feasible if you do something like run git gc every night while you are gone.

I'd recommend looking into something like git annex, which was designed for situations like yours. It basically stores a pointer to large files in your repo rather than the files themselves.

Note: a commit from Git 2.17 (Q2 2018) does point out to the existence of a hook, that git gc --auto will call, and which can be helpful to minimize the effects of that command.

You can read more about git gc --auto in "Understanding git gc --auto".

A sample auto-gc hook (in contrib/) to skip auto-gc while on battery has been updated to almost always allow running auto-gc unless on_ac_power command is absolutely sure that we are on battery power (earlier, it skipped unless the command is sure that we are on ac power).

See commit 781262c (28 Feb 2018) by Adam Borowski (kilobyte).
(Merged by Junio C Hamano -- gitster -- in commit b423234, 14 Mar 2018)

hooks/pre-auto-gc-battery: allow gc to run on non-laptops

Desktops and servers tend to have no power sensor, thus on_ac_power returns 255 ("unknown"). Thus, let's take any answer other than 1 ("battery") as no contraindication to run gc.

If that tool returns "unknown", there's no point in querying other sources as it already queried them, and is smarter than us (can handle multiple adapters).

So, depending on your case, setting up that hook can help you having a say as to wether git gc --auto should execute or not.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!