0

I deleted a branch and I was presuming that a certain commit (let's call it C) was no longer reachable. I was able to find the commit in question using git reflog. However, I am puzzled by the fact that that commit doesn't show up when I do:

git fsck --unreachable --no-reflogs

I was expecting that C was unrechable, and yet it doesn't show up in the output of the above command.

So, the question is: Given a commit C, is there a way to understand how C is reached? git describe does the opposite, in a sense, of what I am trying to achieve. When I do git describe C I get the tag that is reachable from C whereas I want to opposite. I want to understand which tag / branch can be used to reach C, and thus understand why git fsck does not report it as unreachable.

Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
  • 1
    Also, do note that "reachable" and "not collected" does not follow the same rules. A commit can be unreachable, but not yet collected, and thus if you have the SHA of the commit, you can still access it. – Lasse V. Karlsen Mar 09 '22 at 11:09
  • Since I am specifically invoking `git fsck --no-reflogs` I understand that the reflog does not affect commit reachability. The commit is not collected as I was able to resurrect it with `checkout -b`. It is also reachable since it fails to show up in `git fsck`. The aim of my question is to understand how its reachable status is determined. – Marcus Junius Brutus Mar 09 '22 at 11:40
  • @IMSoP. Yes and that's the correct answer as it helped me identify another branch that was also used to reach that commit. – Marcus Junius Brutus Mar 09 '22 at 11:42
  • @IMSoP I voted to close it as duplicate but it seems that that's all I can do – Marcus Junius Brutus Mar 09 '22 at 11:52

0 Answers0