Vim field guide · dot-files

fugitive

Full git porcelain inside Vim. Lazy-loaded on first use of any `:Git` command.

The status window

:Git

Opens a status buffer. Everything you need is one key away from here:

KeyAction
sStage file / hunk under cursor
uUnstage file / hunk
=Toggle inline diff for file under cursor
dvOpen a vertical diff split
ccCommit staged changes (opens message buffer)
caAmend last commit
czStash
XDiscard change
<Enter>Open file
g?Show all available keys

Diff

CommandAction
:GdiffsplitVertical diff of current file vs index
:Gdiffsplit HEADDiff vs last commit
:Gdiffsplit mainDiff vs a branch

In the diff view, use standard Vim diff motions:

KeyAction
]cNext difference
[cPrevious difference
doObtain change from other buffer
dpPut change into other buffer

Blame

:Git blame

Opens an interactive blame split. Navigate with:

KeyAction
<Enter>Open the blamed commit
oOpen commit in a split
~Jump to grandparent commit
qClose blame

For a quick inline summary of who last touched the current line, use the custom :Blame command (plugin/git_helpers.vim).

Log

CommandAction
:Git logFull repo log
:Git log %Log for the current file only
:GclogLoad file log into the quickfix list

Press <Enter> on any commit in the log to open it.

Reading and writing

CommandAction
:GwriteStage current file (equivalent to git add %)
:GreadRevert current file to index (equivalent to git checkout %)

Lazy-loading note

Fugitive and vim-rhubarb are loaded together the first time any of these commands is used:

:Git  :G  :Gblame  :Glog  :Gclog  :Gdiffsplit  :Gvdiffsplit  :GBrowse  …