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.exein a /bin folder andgit.cmdin a /cmd folder.git.cmdis a batch script which wrapsgit.exeand does some other stuff.Both of these directories were in my PATH, with /cmd coming first, so when I typed
git,git.cmdwas 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.
The Lesson Is…
Only use git.exe when using Git for Windows with PowerShell!