From 18ab6ee5bf060b35864dc84ab5593d7fa4cbcc51 Mon Sep 17 00:00:00 2001 From: Borek Bernard Date: Sun, 27 Aug 2017 15:00:06 +0200 Subject: [PATCH 1/2] Ancestry references: note about caret for Windows users Also, the full character names "caret" and "tilde" are mentioned. --- .../sections/revision-selection.asc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/book/07-git-tools/sections/revision-selection.asc b/book/07-git-tools/sections/revision-selection.asc index 887d40ac9..e2d8d5871 100644 --- a/book/07-git-tools/sections/revision-selection.asc +++ b/book/07-git-tools/sections/revision-selection.asc @@ -178,7 +178,7 @@ Running `git show HEAD@{2.months.ago}` will work only if you cloned the project ==== Ancestry References The other main way to specify a commit is via its ancestry. -If you place a `^` at the end of a reference, Git resolves it to mean the parent of that commit. +If you place a `^` (caret) at the end of a reference, Git resolves it to mean the parent of that commit. Suppose you look at the history of your project: [source,console] @@ -207,6 +207,21 @@ Date: Thu Dec 11 15:08:43 2008 -0800 Merge commit 'phedders/rdocs' ---- +[NOTE] +.CARET NEEDS TO BE QUOTED ON WINDOWS +==== + +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: + +[source,console] +---- +$ git show HEAD^ # will NOT work on Windows +$ git show HEAD^^ # OK +$ git show "HEAD^" # OK +---- + +==== + You can also specify a number after the `^` – for example, `d921970^2` means ``the second parent of d921970.'' This syntax is only useful for merge commits, which have more than one parent. 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 Some rdoc changes ---- -The other main ancestry specification is the `~`. +The other main ancestry specification is the `~` (tilde). This also refers to the first parent, so `HEAD~` and `HEAD^` are equivalent. The difference becomes apparent when you specify a number. `HEAD~2` means ``the first parent of the first parent,'' or ``the grandparent'' – it traverses the first parents the number of times you specify. From 50b4e0e0a5b8294e4dcb21512dc0d04f745e8f9f Mon Sep 17 00:00:00 2001 From: Borek Bernard Date: Tue, 29 Aug 2017 00:40:02 +0200 Subject: [PATCH 2/2] Updated [NOTE] title --- book/07-git-tools/sections/revision-selection.asc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/07-git-tools/sections/revision-selection.asc b/book/07-git-tools/sections/revision-selection.asc index e2d8d5871..bb79cec40 100644 --- a/book/07-git-tools/sections/revision-selection.asc +++ b/book/07-git-tools/sections/revision-selection.asc @@ -208,7 +208,7 @@ Date: Thu Dec 11 15:08:43 2008 -0800 ---- [NOTE] -.CARET NEEDS TO BE QUOTED ON WINDOWS +.Escaping the caret on Windows ==== 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: