Listing and deleting Git commits that are under no branch (dangling?)

Posted by Samer Abukhait on Stack Overflow See other posts from Stack Overflow or by Samer Abukhait
Published on 2010-09-21T23:29:30Z Indexed on 2010/12/24 22:54 UTC
Read the original article Hit count: 221

Filed under:
|
|

I've got a git repository with plenty of commits that are under no particular branch, I can git show them but when I try to list branches that contain them, it reports back nothing:

I thought this is the dangling commits/tree issue (as a result of -D branch), so I pruned the repo, but I still see the case after that:

$ git fetch origin

$ git fsck --unreachable
$ git fsck

No output, nothing dangling (right?)

$ git show 793db7f272ba4bbdd1e32f14410a52a412667042
commit 793db7f272ba4bbdd1e32f14410a52a412667042
Author: ..

But

$ git branch --contains 793db7f272ba4bbdd1e32f14410a52a412667042

Gives no output

What exactly is the state of that commit? How can I list all commits with similar state, How can I delete commits like those?

© Stack Overflow or respective owner

Related posts about git

Related posts about branch