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
First of all, there is a
reflogwhich keeps track of all branch history. By default it is 90 days (gc.reflogExpire).Also there is
gc.reflogExpireUnreachablewhich is 30 days. So, if you have madereseton a branch the dangling commit will be here for 30 days accessible viafsck.Also, there is a garbage collector prune settings, which drop dangling objects after 2 weeks by default (
gc.pruneExpireconfig 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)?
cleanremoves untracked files from your working copy, it is unrelated to the blobs/commits.