2
git version 1.7.11.4

Is there any safe way to get rid of the dangling blobs/commits. I just worry in case I accidentally delete something.

git fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (13017/13017), done.
dangling blob 6b9542f29f534b377f9ad280d6d342a4114146ec
dangling blob 0d1779fc8bac49a45b216e1891345b7f69ee068c
dangling blob f8ae5bad210ac84d66d28cb723dcad5b3f325bff
dangling blob e84f8c37c239bc591a52b1169669fb8f593b39b2
dangling blob 5d605b5d6ca0c7cb8d1bc05607eefada2092219b
dangling blob 9363f36de455d504cba3e78fbfb0cb133292fe55
dangling blob 0df63ff9133cc21b45a417958cb012689ebdc4cd
dangling commit fe764632c9d283b558f1326c56f940b3f3aea931
dangling blob b67bedfd9682fbc84f38d44b5112087dff004adc

I have tried the following:

git gc --auto
git clean -f
Holger Just
  • 52,918
  • 14
  • 115
  • 123
ant2009
  • 27,094
  • 154
  • 411
  • 609
  • In general, you can just leave them there. They'll do no harm and just hang around until they age out of use and get picked up by `git gc`. – me_and Sep 12 '12 at 20:34

1 Answers1

2

First of all, there is a reflog which keeps track of all branch history. By default it is 90 days (gc.reflogExpire). Also there is gc.reflogExpireUnreachable which is 30 days. So, if you have made reset on a branch the dangling commit will be here for 30 days accessible via fsck.

Also, there is a garbage collector prune settings, which drop dangling objects after 2 weeks by default (gc.pruneExpire config setting).

Regarding how to wipe out objects from a repository you could read other questions here, e.g. How to REALLY delete a git branch (i.e. remove all of its objects/commits)?

clean removes untracked files from your working copy, it is unrelated to the blobs/commits.

Community
  • 1
  • 1
kan
  • 28,279
  • 7
  • 71
  • 101
  • 1
    strange how all git answers only throw you into more git questions... I had a perfect repo. pushed a branch (and by mistake asked to also push all tags). server failed the push. Since then - I have 2 dangling blobs I do not need (saw their contents). However NOTHING will remove them. How to use this reflog and other terms I don't understand? – Motti Shneor Jun 08 '21 at 17:06