Show the ancestry paths to commit A
from a set of others:
Show all the unreachable commits in the repo:
git fsck
--unreachable --no-reflogs \
| awk '$2 == "commit" {print $3}'
Trace all descendants of commit A
anywhere in the repo:
git log --ancestry-path --graph --decorate --oneline ^A \
--all $(git fsck --unreachable --no-reflogs | awk '$2=="commit" {print $3}')
Git has since this answer was written learned an easier way to show all references whose history includes a commit:
git for-each-ref --contains A
to which you can add --format="%(refname:short)"
to clean up the output.