Git Gui: Perpetually getting "This repository currently has approximately 320 loose objects."

Every time I start Git Gui on a particular project I get this message:

This repository currently has approximately 320 loose objects.

enter image description here

I then proceed to click Yes, and I get this dialog:

enter image description here

The thing is, when I open Git Gui again, I get the exact same message, again about 320 loose objects! It's as if clicking Yes had no effect at all.


Just simply skipping the pop up, as How to skip "Loose Object" popup when running 'git gui' suggests in the accepted answer is overlooking the fact that Git is communicating a possible performance issue to you. This should be fixable by running this command from the command line:

cd path/to/your/git/repo
git gc --aggressive

From the output of git help gc:

Runs a number of housekeeping tasks within the current repository, such as compressing file revisions (to reduce disk space and increase performance) and removing unreachable objects which may have been created from prior invocations of git add.

Users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance.

--aggressive

Usually git gc runs very quickly while providing good disk space utilization and performance. This option will cause git gc to more aggressively optimize the repository at the expense of taking much more time. The effects of this optimization are persistent, so this option only needs to be used occasionally; every few hundred changesets or so.

This should keep the prompt from popping up for a while.


I use command:

git gc --prune=now

and no more too many loose object warning after done.

source of reference: https://git-scm.com/docs/git-gc