loading...

re: git reflog saved my ass. VIEW POST

FULL DISCUSSION
 

Whoa. Thanks for this. I also didn't realize they had that difference. But it does make sense that you'd need a way to specify which parent to choose, when more than one exist.

still not sure what’s the difference between HEAD^ and HEAD~

I'd summarize as: when a commit has more than one parent, ^ lets you say which one you want, ~ always returns the first.

What's confusing is that each can take a number, but treats it differently. <rev>^2 means "rev's second parent" and <rev>~2 means "rev's leftmost grandparent." It might help to think of merge commits as having left and right parents (^1 and ^2), but technically they can have more than 2.

Kinda weird why git log doesn’t show the commits.

My guess is the commits became unreachable. The commits are like a tree* where some of the leaves have markers (either tags or branches) pointing to them. Any commit that's pointed to by a marker or another commit is reachable. git log, despite the name, is just a list of the reachable commits.

Unreachable commits eventually get deleted. The reflog lists every commit, but being in the reflog doesn't prevent deletion.


* technically a DAG, because multiple parents are possible.

Code of Conduct Report abuse