Skip to content

Commit f292a0f

Browse files
authored
Merge pull request #787 from borekb/patch-1
Ancestry references: note about caret for Windows users
2 parents b187fa9 + 50b4e0e commit f292a0f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

book/07-git-tools/sections/revision-selection.asc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Running `git show HEAD@{2.months.ago}` will work only if you cloned the project
178178
==== Ancestry References
179179

180180
The other main way to specify a commit is via its ancestry.
181-
If you place a `^` at the end of a reference, Git resolves it to mean the parent of that commit.
181+
If you place a `^` (caret) at the end of a reference, Git resolves it to mean the parent of that commit.
182182
Suppose you look at the history of your project:
183183

184184
[source,console]
@@ -207,6 +207,21 @@ Date: Thu Dec 11 15:08:43 2008 -0800
207207
Merge commit 'phedders/rdocs'
208208
----
209209

210+
[NOTE]
211+
.Escaping the caret on Windows
212+
====
213+
214+
On Windows in `cmd.exe`, `^` is a special character and needs to be treated differently. You can either double it or put the commit reference in quotes:
215+
216+
[source,console]
217+
----
218+
$ git show HEAD^ # will NOT work on Windows
219+
$ git show HEAD^^ # OK
220+
$ git show "HEAD^" # OK
221+
----
222+
223+
====
224+
210225
You can also specify a number after the `^` – for example, `d921970^2` means ``the second parent of d921970.''
211226
This syntax is only useful for merge commits, which have more than one parent.
212227
The first parent is the branch you were on when you merged, and the second is the commit on the branch that you merged in:
@@ -228,7 +243,7 @@ Date: Wed Dec 10 22:22:03 2008 +0000
228243
Some rdoc changes
229244
----
230245

231-
The other main ancestry specification is the `~`.
246+
The other main ancestry specification is the `~` (tilde).
232247
This also refers to the first parent, so `HEAD~` and `HEAD^` are equivalent.
233248
The difference becomes apparent when you specify a number.
234249
`HEAD~2` means ``the first parent of the first parent,'' or ``the grandparent'' – it traverses the first parents the number of times you specify.

0 commit comments

Comments
 (0)