2017-06-17 95 views
0

當我在git commit消息中使用路徑規範時,它們在系統絕對路徑中被解析!關閉提交消息中的git路徑解析

E.g.

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

將導致

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

我如何關閉這個 '功能'?

我的git版本是2.12.0.windows.1

+2

嘗試使用單引號而不使用雙引號。或者只是'git commit'並通過vim添加消息。 – jonrsharpe

+0

@jonrsharpe,非常感謝!這個對我有用! – kalaider

+0

這看起來像是Git Bash中的一個bug。我爲它打開了一個[issue](https://github.com/git-for-windows/git/issues/1211)。 – Pockets

回答

1

事實證明,這是一個known issue in Git for Windowsissue tracker link)。解決方法是使用MSYS_NO_CONV

如果指定以斜槓開始的命令行選項,則POSIX到Windows路徑轉換將轉換如「/usr/bin/bash.exe」到「C:\Program Files\Git\usr\bin\bash.exe」。當不需要時 - 例如「--upload-pack=/opt/git/bin/git-upload-pack」或「-L/regex/」 - 你需要設置環境變量MSYS_NO_PATHCONV是暫時的,就像這樣:

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

或者,你可以雙擊第一個斜線,以避免POSIX到Windows路徑的轉換,例如「//usr/bin/bash.exe」。