I'm using git at the command line with PowerShell, and I'm trying to use something like
git difftool HEAD^
Powershell seems to treat this as if I typed
git difftool HEAD
so the caret symbol is gone. If I use multiple copies of the caret, I get a weird error:
git difftool HEAD^^
fatal: ambiguous argument 'HEAD@set': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
Interestingly, using four carets in a row seems to escape down to one, so git difftool HEAD^^^^
works as I expect git difftool HEAD^
to work.
I've tried escaping the caret with single quotes, double quotes, grave accents, nothing seems to help.
Is this a feature of PowerShell, or is my setup wrong somewhere?
I found the problem, and it was with my setup :(
I'm using Git for Windows, which provides git.exe
in a /bin folder and git.cmd
in a /cmd folder. git.cmd
is a batch script which wraps git.exe
and does some other stuff.
Both of these directories were in my PATH, with /cmd coming first, so when I typed git
, git.cmd
was being run. Because this was a batch script the caret could not be used. In the cmd world a caret is escaped by typing two of them (^^
).
I guess that this was somehow being required twice, so four carets would be escaped down to two, then one (I don't really understand this bit). I also don't understand the error message when two or three carets are used.
Only use git.exe when using Git for Windows with PowerShell!
You might be able to use ~ instead of ^
git difftool HEAD~
Note that HEAD^^ is the same as HEAD~2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With