Do I ever need to run git gc on a bare repo?

前端 未结 5 1397
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 00:40

man git-gc doesn\'t have an obvious answer in it, and I haven\'t had any luck with Google either (although I might have just been using the wrong search terms).

I un

5条回答
  •  無奈伤痛
    2020-12-03 01:17

    The issue with git gc --auto is that it can be blocking.

    But with the new (Git 2.0 Q2 2014) setting gc.autodetach, you now can do it without any interruption:

    See commit 4c4ac4d and commit 9f673f9 (Nguyễn Thái Ngọc Duy, aka pclouds):

    gc --auto takes time and can block the user temporarily (but not any less annoyingly).
    Make it run in background on systems that support it.
    The only thing lost with running in background is printouts. But gc output is not really interesting.
    You can keep it in foreground by changing gc.autodetach.


    Note: only git 2.7 (Q4 2015) will make sure to not loose the error message.
    See commit 329e6e8 (19 Sep 2015) by Nguyễn Thái Ngọc Duy (pclouds).
    (Merged by Junio C Hamano -- gitster -- in commit 076c827, 15 Oct 2015)

    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
    .

提交回复
热议问题