9

After an unexpected shutdown, now git seemingly works fine but each time is run is asking for compression since it finds 256 loose objects. Is it possible to be cleaned?

j riv
  • 3,593
  • 6
  • 39
  • 54
  • 1
    Have you tried running `git gc`? (And you're not talking about the 256 duplicate objects that in some repos always appear while running `gc`, are you? I think that's just an artifact of the way it performs the compression.) – Cascabel Oct 22 '10 at 13:11
  • 1
    Have you tried `git fsck`? Also you can clone your repo to get a clean .git directory. – Rudi Oct 22 '10 at 14:12

2 Answers2

17

Run git gc. If that doesn't work, please copy the error message.

Jeff Ferland
  • 17,832
  • 7
  • 46
  • 76
  • Thanks; that fixed it. I guess the unexpected shutdown left some unnecessary files around that confused the default system startup. – j riv Oct 23 '10 at 16:54
  • After `git gc` also run `git prune`. – gilyen Jul 11 '18 at 11:56
  • What does these commands do? Are we supposed to (1) run them blindly or (2) Google it before doing it? :) Could you please include a very short explanation as to why run `git gc` (and/or what does it do) and should we run `git prune` too and why? Thanks folks! (EDIT: Or at least link them :p) – jeromej Jul 18 '18 at 12:56
  • See some explanation here: http://alblue.bandlem.com/2011/11/git-tip-of-week-gc-and-pruning-this.html – gilyen Jul 19 '18 at 14:04
1

I had the same issue, git gc did not solve it for me (even with the most aggressive etc. options). But it worked:

git config --global gui.gcwarning false

(it suppresses the window pop-up that is really annoying) See How to skip "Loose Object" popup when running 'git gui'

Community
  • 1
  • 1
gilyen
  • 81
  • 1
  • 4
  • 2
    Ouch! "There is no problem if I can't see it!". Although I do understand it can be quite annoying if you didn't manage to fix and your git works fine anyway. – jeromej Jul 18 '18 at 12:44
  • Running `git gc` then `git prune` solves it, as I have learned-experienced meanwhile. See also http://alblue.bandlem.com/2011/11/git-tip-of-week-gc-and-pruning-this.html – gilyen Jul 19 '18 at 14:02