0

I have a mirror cloned repository on which I wanted to try git gc.

When I check the disk usage before and after using git gc, it actually increase the usage.

Will there be any case in which it actually increases the usage?

enter image description here

Underoos
  • 4,708
  • 8
  • 42
  • 85

1 Answers1

0

Run git count-objects -v before and after git gc. Most likely you will observe that there are more loose objects after the gc than before. The reason is that unreferenced objects are expunged from the object packs and made loose objects. This way, they gain another 2 weeks of lease of life. This is a safety measure in case that there are concurrent operations on the repository elsewhere. If you are certain that there are no other potential users of the objects, you can prune them right away using

git gc --prune=now
j6t
  • 9,150
  • 1
  • 15
  • 35
  • No difference between `git count-objects -v` before and after `git gc`. Same with before and after `git gc --prune=now`. – Underoos Mar 16 '23 at 07:03