From edf81f0ce5d0f05e4e6551696b32115503ec65bc Mon Sep 17 00:00:00 2001 From: Vegar Vikan Date: Wed, 9 Sep 2020 17:02:34 +0200 Subject: [PATCH 1/3] Add note in Revision Selection about PowerShell I've been struggling with the revision selection syntax `HEAD@{...}` and finally found out it's because of curly braces special meaning in PowerShell. I noticed the NOTE on special handling of caret in cmd.exe on Windows. A similar note about curly braces in PowerShell would have saved me some time and I hope to save fellow developers some time by adding in such a note. Thanks to HonkingGoose for his minor changes. Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- .../07-git-tools/sections/revision-selection.asc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/book/07-git-tools/sections/revision-selection.asc b/book/07-git-tools/sections/revision-selection.asc index 9583b15e3..77f928315 100644 --- a/book/07-git-tools/sections/revision-selection.asc +++ b/book/07-git-tools/sections/revision-selection.asc @@ -180,6 +180,22 @@ Running `git show HEAD@{2.months.ago}` will show you the matching commit only if If you have a UNIX or Linux background, you can think of the reflog as Git's version of shell history, which emphasizes that what's there is clearly relevant only for you and your ``session'', and has nothing to do with anyone else who might be working on the same machine. ==== +[NOTE] +.Escaping brackets in PowerShell +==== + +On Windows in `powershell.exe`, `{` and `}` are special characters and needs to be treated differently. +You can either escape them with a backtick ` or put the commit reference in quotes: + +[source,console] +---- +$ git show HEAD@{0} # will NOT work on Windows +$ git show HEAD@`{0`} # OK +$ git show "HEAD@{0}" # OK +---- + +==== + ==== Ancestry References The other main way to specify a commit is via its ancestry. From e16291cded087f73bf83c571aaf20613fabf99cd Mon Sep 17 00:00:00 2001 From: Vegar Vikan Date: Wed, 9 Sep 2020 17:48:38 +0200 Subject: [PATCH 2/3] Improve language Correct usage of braces vs brackets Rewrite first sentence to flow better, and to explain the braces situation a bit better. Remove "either" from the second sentence, as I think the sentence is better without that word. The "or" in the middle of the sentence makes it clear that there are two choices to deal with the bracket issue. So "either" is not really adding value. Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- book/07-git-tools/sections/revision-selection.asc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/book/07-git-tools/sections/revision-selection.asc b/book/07-git-tools/sections/revision-selection.asc index 77f928315..9c190c76a 100644 --- a/book/07-git-tools/sections/revision-selection.asc +++ b/book/07-git-tools/sections/revision-selection.asc @@ -181,11 +181,11 @@ If you have a UNIX or Linux background, you can think of the reflog as Git's ver ==== [NOTE] -.Escaping brackets in PowerShell +.Escaping braces in PowerShell ==== -On Windows in `powershell.exe`, `{` and `}` are special characters and needs to be treated differently. -You can either escape them with a backtick ` or put the commit reference in quotes: +When using PowerShell on Windows, braces like `{` and `}` are special characters and must be escaped. +You can escape them with a backtick ` or put the commit reference in quotes: [source,console] ---- From b9129edfef00776559f9f30f8db46f227aba4c07 Mon Sep 17 00:00:00 2001 From: Vegar Vikan Date: Wed, 9 Sep 2020 18:13:24 +0200 Subject: [PATCH 3/3] Remove reference to Windows PowerShell on Linux requires the same escapeing of braces as on Windows Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- book/07-git-tools/sections/revision-selection.asc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book/07-git-tools/sections/revision-selection.asc b/book/07-git-tools/sections/revision-selection.asc index 9c190c76a..17b5ab60d 100644 --- a/book/07-git-tools/sections/revision-selection.asc +++ b/book/07-git-tools/sections/revision-selection.asc @@ -184,12 +184,12 @@ If you have a UNIX or Linux background, you can think of the reflog as Git's ver .Escaping braces in PowerShell ==== -When using PowerShell on Windows, braces like `{` and `}` are special characters and must be escaped. +When using PowerShell, braces like `{` and `}` are special characters and must be escaped. You can escape them with a backtick ` or put the commit reference in quotes: [source,console] ---- -$ git show HEAD@{0} # will NOT work on Windows +$ git show HEAD@{0} # will NOT work $ git show HEAD@`{0`} # OK $ git show "HEAD@{0}" # OK ----