2021-02-01 07:47:23 +01:00
|
|
|
nnoremap <Leader>ga :Git fetch --all<CR>
|
|
|
|
xnoremap <Leader>gb :Git blame<CR>
|
2021-04-15 07:32:48 +02:00
|
|
|
nnoremap <Leader>gb :Git branch -a<CR>
|
|
|
|
nnoremap <Leader>gB :Git branch<SPACE>
|
|
|
|
nnoremap <Leader>gc :Git checkout -b<SPACE>
|
|
|
|
nnoremap <Leader>gC :Git checkout<SPACE>
|
2021-02-01 07:47:23 +01:00
|
|
|
nnoremap <Leader>gd :Ghdiffsplit!<CR>
|
|
|
|
nnoremap <Leader>gD :Gvdiffsplit!<CR>
|
2021-04-15 07:32:48 +02:00
|
|
|
nnoremap <Leader>gl :Git log %<CR>
|
|
|
|
nnoremap <Leader>gL :Git log -n 100<CR>
|
|
|
|
xnoremap <Leader>gl :<C-U>call <SID>git_log_range()<CR>
|
|
|
|
xnoremap <Leader>gL :<C-U>call <SID>git_log_named_block()<CR>
|
|
|
|
nnoremap <Leader>gM :Git merge origin/
|
2021-02-01 07:47:23 +01:00
|
|
|
nnoremap <Leader>gp :Git push<CR>
|
|
|
|
nnoremap <Leader>gP :Git push -u<SPACE>
|
2021-04-15 07:32:48 +02:00
|
|
|
nnoremap <Leader>gr :Git rebase origin/master<CR>
|
|
|
|
nnoremap <Leader>gR :Git rebase origin/main<CR>
|
2021-02-01 07:47:23 +01:00
|
|
|
nnoremap <Leader>g- :Git stash<CR>:e<CR>
|
|
|
|
nnoremap <Leader>g+ :Git stash pop<CR>:e<CR>
|
2021-04-15 07:32:48 +02:00
|
|
|
nnoremap <Leader>gs :Git<CR>
|
|
|
|
nnoremap <Leader>gS :Git<SPACE>
|
2021-02-01 07:47:23 +01:00
|
|
|
nnoremap <Leader>gw :Gwrite<CR>
|
|
|
|
|
|
|
|
" For 3 way merge
|
|
|
|
nnoremap <Leader>dl :diffget //2<CR>
|
|
|
|
nnoremap <Leader>dr :diffget //3<CR>
|
|
|
|
|
|
|
|
" The next two functions allow scoping diffs by line range of a file and named
|
|
|
|
" block in a file. Inspired by reading the following article.
|
|
|
|
" https://susanpotter.net/software/tracking-diffs-by-scoping-to-file-range-function-method-or-class-changes-in-git/
|
|
|
|
|
|
|
|
" Use these two links as reference to come up with this function
|
|
|
|
" https://vi.stackexchange.com/questions/17606/vmap-and-visual-block-how-do-i-write-a-function-to-operate-once-for-the-entire
|
|
|
|
" https://stackoverflow.com/questions/41238238/how-to-map-vim-visual-mode-to-replace-my-selected-text-parts
|
|
|
|
function! s:git_log_range() abort
|
|
|
|
let [lnum1, col1] = getpos("'<")[1:2]
|
|
|
|
let [lnum2, col2] = getpos("'>")[1:2]
|
|
|
|
silent execute "Git log --no-patch -L " . lnum1 . "," . lnum2 . ":%"
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Taken from https://learnvimscriptthehardway.stevelosh.com/chapters/33.html.
|
|
|
|
" Modified and stripped to do what I needed.
|
|
|
|
function! s:git_log_named_block() abort
|
|
|
|
normal! `<v`>y
|
|
|
|
silent execute "Git log --no-patch -L :" . shellescape(@@) . ":%"
|
|
|
|
endfunction
|