After doing
git commit -am '/logs whatever'
I end up with commit message C:/Program Files/Git/logs whatever
. How does this happen? I did not succeed in finding any related information by googling things like 'git commit message autocomplete'.
$ git --version
git version 2.20.1.windows.1
$ bash --version
GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
Additional investigation The path does not have to exist, it's just appended to C:/Program Files/Git
, but if it exists, things can be different (notice /usr/
, both paths exist):
$ git commit -am '/bin/git.exe something'
[master 22f9915] C:/Program Files/Git/usr/bin/git.exe something
Apparently, this is a known issue . Johannes Schindelin, maintainer of Git for Windows, describes it and possible fixes:
If you specify command-line options starting with a slash, POSIX-to-Windows path conversion will kick in converting eg "
/usr/bin/bash.exe
" to "C:\\Program Files\\Git\\usr\\bin\\bash.exe
". When that is not desired -- eg "--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.
Even though in your case this is not a path as such, just the fact that the message starts with a slash must be triggering this behavior.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.