As you know :G generally applies for the git directory of the current file.

How do you make it work for the current working directory?

1 Answer 1


Here I defined :GCWD for current working folder.

function! GitDir()
let top = systemlist("git rev-parse --show-toplevel")[0]
return top . "/.git"

function! GCWDComplete(A, L, P) abort
return fugitive#Complete(a:A, a:L, a:P, {'git_dir': GitDir()})

command! -bang -nargs=? -range=-1 -complete=customlist,GCWDComplete GCWD exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>,   { 'git_dir': GitDir() })

based mainly on others code (https://github.com/tpope/vim-fugitive/issues/1981 ), so made it a wiki.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.