How to do it...

  1. To switch off automatic garbage collection from being triggered, we need to set the gc.auto configuration to 0. First, we'll check the existing setting, and then we can set it and verify the configuration using the following commands:
$ git config gc.auto # exit code is 1 when not set$ echo $?1
$ git config gc.auto 0 
$ git config gc.auto 
0
  1. Now we can try to run git gc with the --auto flag, as it will be called when normally triggered from an other command:
$ git gc --auto
  1. As expected, nothing happens, as the configuration disables automatic garbage collection. We can still trigger it manually though (without the --auto flag):
$ git gc 
Counting objects: 51, done. 
Delta compression using up to 8 threads. 
Compressing objects: ...

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.