112

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.

sashoalm
  • 75,001
  • 122
  • 434
  • 781
  • 1
    Can you post the output of `git count-objects -v` ? – CB Bailey Jan 30 '14 at 13:09
  • possible duplicate of [How to skip "Loose Object" popup when running 'git gui'](http://stackoverflow.com/questions/1106529/how-to-skip-loose-object-popup-when-running-git-gui) – TheCodeArtist Jan 30 '14 at 13:11
  • 5
    @TheCodeArtist Thanks, I found the answer there. Running `git gc` explicitly from the command line worked for me, as per [this comment](http://stackoverflow.com/questions/1106529/how-to-skip-loose-object-popup-when-running-git-gui#comment921715_1106656). – sashoalm Jan 30 '14 at 13:53
  • Related, for when even there are unlinking errors while compressing the object database: https://stackoverflow.com/q/11774397/1959808 – 0 _ May 13 '21 at 08:23

2 Answers2

103

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.

Community
  • 1
  • 1
Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92
  • 25
    What is strange is that simply running `git gc` from the command line fixed it for me. May be `git gui` runs something like `git gc --extra-unaggressive` :) – sashoalm Jan 30 '14 at 13:57
  • 2
    It seems that git gui calls `"C:\Program Files\Git\bin\sh.exe" "C:/Program Files/Git/libexec/git-core/git-repack" -a -d -l` – sashoalm Jan 31 '14 at 12:52
  • 41
    `git prune` seems to fix it when `git gc` doesn't. – Mahn Feb 24 '15 at 00:58
  • @Mahn That just worked for me too. (Git 1.7.1) Supposedly `git gc` should call `git prune`, but running it manually it what finally fixed this for me. – Jonathon Reinhart Jun 12 '15 at 14:17
  • 2
    You generally don't want to run with `--aggressive`; that causes `git` to recalculate deltas which is usually unproductive and very time-consuming; see [this post](https://metalinguist.wordpress.com/2007/12/06/)--the `man` page is misleading. Probably just plain `git gc` is enough in this case. – Jeff Clites Jul 09 '15 at 01:05
  • 18
    Had to use `--prune=all` to get rid of the message. Neither `git gc` on the command line nor the options `--aggressive` or `--prune` did the trick. – daw Oct 14 '16 at 19:07
  • 1
    @JeffClites The article you refer to is (as of this date) 11 years old, and states "For this reason --aggressive will probably be removed from the manpages and left as an undocumented feature for a while.". Without digging further, it seems weird that the broken message is still there. Is there a chance that the behavior has been modified sine the article was written? – pipe Mar 21 '18 at 10:41
  • @daw --prune=all is not recognized – Vipin Verma Jul 11 '18 at 11:00
  • 2
    The fact that clicking "Yes" on git gui's popup does not actually address the problem seems like a bug. Is there a place to enter bug reports for git gui? – fr0 Sep 08 '22 at 16:10
10

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

AdvenC
  • 121
  • 1
  • 5
  • 4
    Have to say that this was the solution that worked for me. Strangely, `git gc --aggressive` did not remove the warning (and neither did clicking on the UI, which seems to perform a simple `git gc`). – saeraphin Oct 07 '20 at 06:10