fugitive.vim: A Git wrapper so awesome, it should be illegal
Fugitive is the premier Vim plugin for Git. Or maybe it’s the premier Git
plugin for Vim? Either way, it’s “so awesome, it should be illegal”. That’s
why it’s called Fugitive.
The crown jewel of Fugitive is :Git (or just :G), which calls any
arbitrary Git command. If you know how to use Git at the command line, you
know how to use :Git. It’s vaguely akin to :!git but with numerous
improvements:
:Git add avoid the dreaded “Press ENTER or type command to:Git commit, :Git rebase -i, and other commands that invoke an editor do:Git diff, :Git log, and other verbose, paginated commands have their:Git --paginate or :Git -p.:Git blame uses a temporary buffer with maps for additional triage. Pressg? to see:Git mergetool and :Git difftool load their changesets into the quickfix:Git opens a summary window with dirty files andg? to bring up a list of maps for:Gstatus.)Additional commands are provided for higher level operations:
:Gedit (and:Gsplit, etc.). For example, :Gedit HEAD~3:% loads the current file as:Gdiffsplit (or :Gvdiffsplit) brings up the staged version of the file:Gedit argument to:Gread is a variant of git checkout -- filename that operates on theu to undo it:Gwrite writes to both the work tree and index versions of a file, makinggit add when called from a work tree file and like git checkout:Ggrep is :grep for git grep. :Glgrep is :lgrep for the same.:GMove does a git mv on the current file and changes the buffer name to:GRename does the same with a destination filename relative to the:GDelete does a git rm on the current file and simultaneously deletes:GRemove does the same but leaves the (now empty) buffer:GBrowse to open the current file on the web front-end of your favoriteAdd %{FugitiveStatusline()} to 'statusline' to get an indicator
with the current branch in your statusline.
For more information, see :help fugitive.
Install using your favorite package manager, or use Vim’s built-in package
support:
mkdir -p ~/.vim/pack/tpope/start
cd ~/.vim/pack/tpope/start
git clone https://tpope.io/vim/fugitive.git
vim -u NONE -c "helptags fugitive/doc" -c q
What happened to the dispatch.vim backed asynchronous
:Gpushand
:Gfetch?
This behavior was divisive, confusing, and complicated inputting passwords, so
it was removed. Use :Git! push to use Fugitive’s own asynchronous
execution, or retroactively make :Git push asynchronous by pressing
CTRL-D.
Why am I getting
core.worktree is required when using an external Git dir?
Git generally sets core.worktree for you automatically when necessary, but
if you’re doing something weird, or using a third-party tool that does
something weird, you may need to set it manually:
git config core.worktree "$PWD"
This may be necessary even when simple git commands seem to work fine
without it.
So I have a symlink and…
Stop. Just stop. If Git won’t deal with your symlink, then Fugitive won’t
either. Consider using a plugin that resolves
symlinks, or even better,
using fewer symlinks.
Like fugitive.vim? Follow the repository on
GitHub and vote for it on
vim.org. And if
you’re feeling especially charitable, follow tpope on
Twitter and
GitHub.
Copyright © Tim Pope. Distributed under the same terms as Vim itself.
See :help license.
We use cookies
We use cookies to analyze traffic and improve your experience. You can accept or reject analytics cookies.