3 I'm not going to lie to you; fugitive.vim may very well be the best
4 Git wrapper of all time. Check out these features:
6 View any blob, tree, commit, or tag in the repository with `:Gedit` (and
7 `:Gsplit`, `:Gvsplit`, `:Gtabedit`, ...). Edit a file in the index and
8 write to it to stage the changes. Use `:Gdiff` to bring up the staged
9 version of the file side by side with the working tree version and use
10 Vim's diff handling capabilities to stage a subset of the file's
13 Bring up the output of `git status` with `:Gstatus`. Press `-` to
14 `add`/`reset` a file's changes, or `p` to `add`/`reset` `--patch`. Use
15 `:Gcommit %` to commit the current file, editing the commit message inside
16 the currently running Vim.
18 `:Gblame` brings up an interactive vertical split with `git blame`
19 output. Press enter on a line to edit the commit where the line
20 changed, or `o` to open it in a split. When you're done, use `:Gedit`
21 in the historic buffer to go back to the work tree version.
23 `:Gmove` does a `git mv` on a file and simultaneously renames the
24 buffer. `:Gdelete` does a `git rm` on a file and simultaneously deletes
27 Use `:Ggrep` to search the work tree (or any arbitrary commit) with
28 `git grep`, skipping over that which is not tracked in the repository.
29 `:Glog` loads all previous revisions of a file into the quickfix list so
30 you can iterate over them and watch the file evolve!
32 `:Gread` is a variant of `git checkout -- filename` that operates on the
33 buffer rather than the filename. This means you can use `u` to undo it
34 and you never get any warnings about the file changing outside Vim.
35 `:Gwrite` writes to both the work tree and index versions of a file,
36 making it like `git add` when called from a work tree file and like
37 `git checkout` when called from the index or a blob in history.
39 Use `:Gbrowse` to open the current file on the web front-end of your favorite
40 hosting provider, with optional line range (try it in visual mode!). Plugins
41 are available for popular providers such as [GitHub][rhubarb.vim],
42 [GitLab][fugitive-gitlab.vim], and [Bitbucket][fubitive.vim].
44 [rhubarb.vim]: https://github.com/tpope/vim-rhubarb
45 [fugitive-gitlab.vim]: https://github.com/shumphrey/fugitive-gitlab.vim
46 [fubitive.vim]: https://github.com/tommcdo/vim-fubitive
48 Add `%{FugitiveStatusline()}` to `'statusline'` to get an indicator
49 with the current branch in (surprise!) your statusline.
51 Last but not least, there's `:Git` for running any arbitrary command,
52 and `Git!` to open the output of a command in a temp file.
56 * [A complement to command line git](http://vimcasts.org/e/31)
57 * [Working with the git index](http://vimcasts.org/e/32)
58 * [Resolving merge conflicts with vimdiff](http://vimcasts.org/e/33)
59 * [Browsing the git object database](http://vimcasts.org/e/34)
60 * [Exploring the history of a git repository](http://vimcasts.org/e/35)
64 If you don't have a preferred installation method, one option is to install
65 [pathogen.vim](https://github.com/tpope/vim-pathogen), and then copy
69 git clone https://github.com/tpope/vim-fugitive.git
70 vim -u NONE -c "helptags vim-fugitive/doc" -c q
72 If your Vim version is below 7.2, I recommend also installing
73 [vim-git](https://github.com/tpope/vim-git) for syntax highlighting and
78 > Why don't any of the commands exist?
80 Fugitive cares about the current file, not the current working directory.
81 Edit a file from the repository. To avoid the blank window problem, favor
82 commands like `:split` and `:tabedit` over commands like `:new` and `:tabnew`.
84 > Here's a patch that automatically opens the quickfix window after
87 This is a great example of why I recommend asking before patching.
88 There are valid arguments to be made both for and against automatically
89 opening the quickfix window. Whenever I have to make an arbitrary
90 decision like this, I ask what Vim would do. And Vim does not open a
91 quickfix window after `:grep`.
93 Luckily, it's easy to implement the desired behavior without changing
94 fugitive.vim. The following autocommand will cause the quickfix window
95 to open after any grep invocation:
97 autocmd QuickFixCmdPost *grep* cwindow
101 Like fugitive.vim? Follow the repository on
102 [GitHub](https://github.com/tpope/vim-fugitive) and vote for it on
103 [vim.org](http://www.vim.org/scripts/script.php?script_id=2975). And if
104 you're feeling especially charitable, follow [tpope](http://tpo.pe/) on
105 [Twitter](http://twitter.com/tpope) and
106 [GitHub](https://github.com/tpope).
110 Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.