That's a shortcut I've been using for a while to push my commits to the current branch that I'm working on.
" ~/.vimrc " Write COMMIT_EDITMSG and push to current branch function! PushToCurrentBranch() exe ":Gwrite" let branch = fugitive#statusline() let branch = substitute(branch, '\c\v\[?GIT\(([a-z0-9\-_\./:]+)\)\]?', $BRANCH.' \1', 'g') exe ":Git push origin" . branch endfunction " Map gwp keys to call the function nnoremap gwp :call PushToCurrentBranch()<CR>
It assumes that you are on :Gstatus buffer.
You can check out my entire VIM configuration here: https://github.com/endel/.vim/