在提交消息中关闭 git 路径解析
Turn off git path resolution in commit message
当我在 git 提交消息中使用路径规范时,它们在系统绝对路径中解析!
例如
git commit -m "/tools/controller subproject moved to submodule"
将导致
C:/Program Files/Git/tools/controller subproject moved to submodule
如何关闭此 'feature'?
我的 git 版本是 2.12.0.windows.1
。
原来这是当前一个known issue in Git for Windows (issue tracker link)。解决方法是使用 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
".
当我在 git 提交消息中使用路径规范时,它们在系统绝对路径中解析!
例如
git commit -m "/tools/controller subproject moved to submodule"
将导致
C:/Program Files/Git/tools/controller subproject moved to submodule
如何关闭此 'feature'?
我的 git 版本是 2.12.0.windows.1
。
原来这是当前一个known issue in Git for Windows (issue tracker link)。解决方法是使用 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 variableMSYS_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
".