Skip to content

Commit edf81f0

Browse files
vegarHonkingGoose
authored andcommitted
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 <[email protected]>
1 parent 1bd697e commit edf81f0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,22 @@ Running `git show HEAD@{2.months.ago}` will show you the matching commit only if
180180
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.
181181
====
182182

183+
[NOTE]
184+
.Escaping brackets in PowerShell
185+
====
186+
187+
On Windows in `powershell.exe`, `{` and `}` are special characters and needs to be treated differently.
188+
You can either escape them with a backtick ` or put the commit reference in quotes:
189+
190+
[source,console]
191+
----
192+
$ git show HEAD@{0} # will NOT work on Windows
193+
$ git show HEAD@`{0`} # OK
194+
$ git show "HEAD@{0}" # OK
195+
----
196+
197+
====
198+
183199
==== Ancestry References
184200

185201
The other main way to specify a commit is via its ancestry.

0 commit comments

Comments
 (0)