Git: automatic clean-up?

3.8k views Asked by At

In the past, one had to invoke git gc from time to time. I've read now, that latest Git versions should perform the cleanup automatically. Is this correct?

2

There are 2 answers

0
D-Rock On BEST ANSWER

To an extent...

From the documentation at http://www.kernel.org/pub/software/scm/git/docs/git-gc.html

Pertaining to git gc --auto....

With this option, git gc checks whether any housekeeping is required; if not, it exits without performing any work. Some git commands run git gc --auto after performing operations that could create many loose objects.

So it depends on the commands you are running.

0
Sergey K. On

You can setup a cron task as explained here: http://minhajuddin.com/2011/12/09/gc-your-git-repositories-automatically-with-a-cron-task

As the git help gc says: users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance.

Some git commands may automatically run git gc. 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

Also, you can configure prune behaviour:

git config gc.pruneexpire "30 days"