From: dieter@schoen.or.at Date: Mon, 19 Sep 2011 09:08:31 GMT Subject: how to remove unreachable objects? Message-ID: <20110919110831.ewq03vnqos4w8cs8@webmail.edis.at> hi, i am relatively new to git, and am currently trying to get used to it. at the moment i am exploring how to remove unneeded objects, this should be possible with prune, gc and/or fsck. maybe i have not found the right combination or something in my understand is not correct. this is my use case: i create a repository and produce several commits on master. then i go back to a certain tag and create a new branch, where i also commit. then i switch back to master and delete (-D) the other branch. it should now be unreachable from within git (to prove its existence, i remember a commit SHA1 on the dead branch). then i try to get rid of the unreachable objects with a series of prune, fsck and gc. ------------- schoen.d@ax:~/projects/gitFeatures$ cat mk_dead_end.sh #!/bin/sh DEAD=dead_end rm -rf $DEAD mkdir $DEAD cd $DEAD git init echo "first commit" > A git add A git commit -m "first commit" git tag first_commit echo "second commit" >> A git add A git commit -m "second commit" git checkout first_commit echo "commit in dead end" >> A git add A git commit -m "changed A in dead end" git checkout -b $DEAD dead_commit=`git log -1 --format="%H"` git checkout master git branch -D $DEAD git show $dead_commit git fsck --unreachable --full --verbose git fsck --unreachable HEAD \ $(git for-each-ref --format="%(objectname)" refs/heads) git fsck --lost-found git prune -v $dead_commit git prune $(git rev-parse --all) git repack git prune-packed git gc --prune=now git gc --aggressive git show $dead_commit ------ if you look at the output of this script then you see that git knows that there are unreachable/dangling objects, but they remain. thankful for any pointer, dieter