Turning off automatic garbage collection

The automatic triggering of garbage collection can be turned off so it will not run unless manually triggered. This can be useful if you are searching the repository for a lost commit/file and want to make sure that it is not being garbage collected while searching (running Git commands).

Getting ready

We'll use the hello_world_flow_model repository again for this example:

$ git clone https://github.com/dvaske/hello_world_flow_model.git
Cloning into 'hello_world_flow_model'...
remote: Reusing existing pack: 51, done.
remote: Total 51 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (51/51), done.
Checking connectivity... done.
$ cd hello_world_flow_model
$ git checkout develop
Already on 'develop'
Your branch is up-to-date with 'origin/develop'.
$ git reset --hard origin/develop
HEAD is now at 2269dcf Merge branch 'release/1.0' into develop

How to do it...

  1. To switch off the automatic garbage collection triggering, 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
    $ git config gc.auto 0
    $ git config gc.auto
    0
    
  2. Now we can try to run git gc with the --auto option, as it will be called when normally triggered from other command:
    $ git gc --auto
    
  3. 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: 100% (49/49), done.
    Writing objects: 100% (51/51), done.
    Total 51 (delta 23), reused 0 (delta 0)
    
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset