How do I tell fugitive my path to Git on Windows? How do I tell fugitive my path to Git on Windows? git git

How do I tell fugitive my path to Git on Windows?


In your vimrc, add something like the following:

if has('win32')    let $PATH .= ';' . 'C:/Program Files (x86)/Git/bin'endif

This won't affect the value of %PATH% outside of Vim.

Alternatively, to get Fugitive to work as advertised, you'll have to patch it a bit.In s:Git() replace

call s:ExecuteInTree('!'.git.' '.cmd)

with

if has('win32')    call s:ExecuteInTree('!"'.git.' '.cmd.'"')else    call s:ExecuteInTree('!'.git.' '.cmd)endif

and then put quotation marks around the path to the executable in your vimrc:

let g:fugitive_git_executable = '"C:/Program Files (x86)/Git/bin/git"'

(See correct quoting for cmd.exe for multiple arguments.)

You might want to get in touch with the maintainer. I'd be surprised if thisissue hasn't cropped up before.

I just modify $PATH. Some programs require $PATH to be set correctly, anyhow.

(Plus: @echristopherson's solution is perfectly viable, but it's annoying to have to resort to that in the 21st Century.)


The standard directory C:\Program Files (x86) can be abbreviated to C:\Progra~2*. This kind of shortened name is how long filenames or filenames with spaces in them were actually represented on FAT filesystems (which internally are restricted to filenames of eight base characters and three extension characters) from Windows 95 on, but it's still supported for compatibility in modern Windows systems using NTFS, at least in specific cases like the Program Files (x86) folder.

C:\Program Files is, similarly, C:\Progra~1.

* In Vimscript the backslashes should be changed to slashes unless they are either doubled up or enclosed in single quotes.


While the other two answers (1,2) provide workarounds for the problem, playing around showed me that I need to specify the path this way:

let g:fugitive_git_executable = '"C:\\Program Files ^(x86^)\\Git\\cmd\\git.exe"'

Yes, it's really a single quote followed by a double quote AND (as if this wouldn't be odd enough) I need to escape the parentheses with ^( and ^).

Although the issue is solved for me, I got no clue why I have to specify the path this way...