Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: automatic clean-up?

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?

like image 807
Mot Avatar asked Oct 26 '12 11:10

Mot


2 Answers

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.

like image 156
D-Rock Avatar answered Sep 28 '22 07:09

D-Rock


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"
like image 39
Sergey K. Avatar answered Sep 28 '22 07:09

Sergey K.