Skip to content

Commit d8cd988

Browse files
committed
push/pull
1 parent 31d7cee commit d8cd988

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

plugin/git.vim

+22-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ nnoremap <Leader>gl :GitLog<Enter>
1717
nnoremap <Leader>ga :GitAdd<Enter>
1818
nnoremap <Leader>gA :GitAdd <cfile><Enter>
1919
nnoremap <Leader>gc :GitCommit<Enter>
20+
nnoremap <Leader>gp :GitPullRebase<Enter>
2021
2122
" Ensure b:git_dir exists.
2223
function! s:GetGitDir()
@@ -142,10 +143,27 @@ function! GitCheckout(args)
142143
call GitDoCommand('checkout ' . a:args)
143144
endfunction
144145

146+
" Push.
147+
function! GitPush(args)
148+
" call GitDoCommand('push ' . a:args)
149+
" Wanna see progress...
150+
let args = a:args
151+
if args =~ '^\s*$'
152+
let args = 'origin ' . GitBranch()
153+
endif
154+
execute '!' g:git_bin 'push' args
155+
endfunction
156+
157+
" Pull.
158+
function! GitPull(args)
159+
" call GitDoCommand('pull ' . a:args)
160+
" Wanna see progress...
161+
execute '!' g:git_bin 'pull' a:args
162+
endfunction
163+
145164
" Show commit, tree, blobs.
146165
function! GitCatFile(file)
147166
let file = s:Expand(a:file)
148-
"let file_type = s:SystemGit('cat-file -t ' . file)
149167
let git_output = s:SystemGit('cat-file -p ' . file)
150168
if !strlen(git_output)
151169
echo "No output from git command"
@@ -250,3 +268,6 @@ command! -nargs=1 GitCatFile call GitCatFile(<q-args>)
250268
command! -nargs=+ Git call GitDoCommand(<q-args>)
251269
command! GitVimDiffMerge call GitVimDiffMerge()
252270
command! GitVimDiffMergeDone call GitVimDiffMergeDone()
271+
command! GitPull call GitPull(<q-args>)
272+
command! GitPullRebase call GitPull('--rebase')
273+
command! GitPush call GitPush('')

0 commit comments

Comments
 (0)