3 ms·
The way in which the author structured the language used to describe things may be the most confusing thing of all. For example: "HEAD^ and HEAD~ are the same
by esoterae 3y ago
The way in which the author structured the language used to describe things may be the most confusing thing of all. For example:
"HEAD^ and HEAD~ are the same thing (1 commit ago)"
Followed by:
"But I guess they also wanted a way to refer to “3 commits ago”, so HEAD^3 is the third parent of the current commit, and HEAD~3 is the parent’s parent’s parent."
The author's language implies a contradiction they immediately prior said doesn't exist. If these two distinct constructs were indeed different ways to define the same relationship, the second paragraph would say "^3 and ~3 are both ways of saying the third parent of the current commit, or the parent's parent's parent." Instead, they've defined the constructs as different once again.
- deleted 3y ago[deleted]
- jcranmer 3y ago> If these two distinct constructs were indeed different ways to define the same relationship, the second paragraph would say "^3 and ~3 are both ways of saying the third parent of the current commit, or the parent's parent's parent." They're not the same thing. Merge commits can have multiple parents, and HEAD^3 refers to the third parent. If HEAD is not a merge commit, then HEAD^3 doesn't refer to anything. HEAD~3, by contrast, refers to following the parent's parent's parent, independent of how many parents any of the commits in question had.
- dicytea 3y ago> HEAD~3, by contrast, refers to following the parent's parent's parent, More specifically, following the first parent only. man git-rev-parse (surprisingly) has a nice explanation: > A suffix ~<n> to a revision parameter means the commit object that is the <n>th generation ancestor of the named commit object, following only the first parents. I.e. <rev>~3 is equivalent to <rev>^^^ which is equivalent to <rev>^1^1^1.
- ahmedfromtunis 3y agoTo make it even clearer, "^3" is when a team of, say, 4 commits contributed to the current commit. "^3" is then the team member number 3. "~3" however refres to grand-grand-parent to the current commit. It's confusing because ^ looks like an up-arrow, so we think of it as a pointer to look n levels up. That's not the case.