git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* how to remove unreachable objects?
@ 2011-09-19  9:08 dieter
  2011-09-19 19:53 ` Jeff King
  2011-09-19 20:36 ` Andreas Schwab
  0 siblings, 2 replies; 9+ messages in thread
From: dieter @ 2011-09-19  9:08 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-09-24 22:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-19  9:08 how to remove unreachable objects? dieter
2011-09-19 19:53 ` Jeff King
2011-09-19 20:18   ` Jeff King
2011-09-19 21:38     ` Junio C Hamano
2011-09-19 22:52       ` Jeff King
2011-09-20  0:40         ` Junio C Hamano
2011-09-20  0:51           ` Jeff King
2011-09-24 22:11   ` Dieter Schön
2011-09-19 20:36 ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).