Reputation: 199215
I asked this question long ago but I still don't know what do ~ and ^ mean in this answer:
If you're talking about a remote branch, say, origin/master, you can use ~ and ^ to refer to ancestor commits relative to a branch the same way you can with local branches
What's the difference?
Upvotes: 7
Views: 1549
Reputation: 2030
According to this document, tilde (~) references the linear ancestors of the commit (parent, grandparent, great-grandparent), whereas caret (^) references multiple parents. In cases where there are multiple merge ancestors, each merge source would be a parent.
Upvotes: 5
Reputation: 51935
As the manpage states:
<rev>^, e.g. HEAD^, v1.5.1^0
A suffix ^ to a revision parameter means the first parent of that commit object.^<n>
means the<n>
th parent (i.e.<rev>^
is equivalent to<rev>^1
). [...]
<rev>~<n>, e.g. master~3
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
.
Upvotes: 4
Reputation: 410592
^
means "(first) parent of". ~
is similar, but it takes a number as an argument and basically means "ancestor of". So, for example:
HEAD = latest commit
HEAD^ = HEAD~1 = parent of latest commit
HEAD^^ = HEAD~2 = grandparent of latest commit
HEAD~100 = 100th ancestor of latest commit
Upvotes: 7