GitConfig backslash problem IntelliJ mergetool and difftool

343 Views Asked by At

I currently have in C:\Users\me\.gitconfig the following contents

[merge]
    tool = intellij
[mergetool "intellij"]
    cmd = cmd.exe //c "\"C:/Program Files/JetBrains/IntelliJ IDEA 2018.1.5/bin/idea.bat\" merge \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\""
    trustExitCode = true
[diff]
    tool = intellij
[difftool "intellij"]
    cmd = cmd.exe //c "\"C:/Program Files/JetBrains/IntelliJ IDEA 2018.1.5/bin/idea.bat\" diff \"$LOCAL\" \"$REMOTE\""

and when I do git difftool I get

'C:/Program' is not recognized as an internal or external command,
operable program or batch file.

In [Git Docs], it is mentioned that

The following escape sequences (beside \" and \) are recognized: \n for newline character (NL), \t for horizontal tabulation (HT, TAB) and \b for backspace (BS). Other char escape sequences (including octal escape sequences) are invalid.

I also looked at Syntax for specifying Windows paths and tried some combinations:

# Escape spaces
Program\\ Files
Program/ Files
Program\ Files

# Backslashes
C:\Program Files\...
# 'C:\Program' is not recognized

But none worked, what is the right way to do this?

1

There are 1 best solutions below

0
On

One way woud be to test the unix syntax

cmd = "/C/Program Files/JetBrains/IntelliJ IDEA 2018.1.5/bin/idea.bat"...

The other would be to add C:/Program Files/JetBrains/IntelliJ IDEA 2018.1.5/bin to your %PATH%, allowing you to reference the bat file directly.

cmd = cmd.exe /c idea.bat ...