Push changes to your current branch directly from VIM
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/
Written by Endel Dreyer
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#