Search code examples
gitrelative-pathcommit-message

Turn off git path resolution in commit message


When I use path specs in git commit message, they are resolved in system absolute paths!

E.g.

git commit -m "/tools/controller subproject moved to submodule"

will result in

C:/Program Files/Git/tools/controller subproject moved to submodule

How can I turn off this 'feature'?

My git version is 2.12.0.windows.1.


Solution

  • It turns out that this is currently a known issue in Git for Windows (issue tracker link). The workaround is to use MSYS_NO_CONV:

    If you specify command-line options starting with a slash, POSIX-to-Windows path conversion will kick in converting e.g. "/usr/bin/bash.exe" to "C:\Program Files\Git\usr\bin\bash.exe". When that is not desired -- e.g. "--upload-pack=/opt/git/bin/git-upload-pack" or "-L/regex/" -- you need to set the environment variable MSYS_NO_PATHCONV temporarily, like so:

    MSYS_NO_PATHCONV=1 git blame -L/pathconv/ msys2_path_conv.cc

    Alternatively, you can double the first slash to avoid POSIX-to-Windows path conversion, e.g. "//usr/bin/bash.exe".