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`. And guess
17 `:Gblame` brings up an interactive vertical split with `git blame`
18 output. Press enter on a line to edit the commit where the line
19 changed, or `o` to open it in a split. When you're done, use `:Gedit`
20 in the historic buffer to go back to the work tree version.
22 `:Gmove` does a `git mv` on a file and simultaneously renames the
23 buffer. `:Gdelete` does a `git rm` on a file and simultaneously deletes
26 Use `:Ggrep` to search the work tree (or any arbitrary commit) with
27 `git grep`, skipping over that which is not tracked in the repository.
28 `:Glog` loads all previous revisions of a file into the quickfix list so
29 you can iterate over them and watch the file evolve!
31 `:Gread` is a variant of `git checkout -- filename` that operates on the
32 buffer rather than the filename. This means you can use `u` to undo it
33 and you never get any warnings about the file changing outside Vim.
34 `:Gwrite` writes to both the work tree and index versions of a file,
35 making it like `git add` when called from a work tree file and like
36 `git checkout` when called from the index or a blob in history.
38 Use `:Gbrowse` to open the current file on the web front-end of your favorite
39 hosting provider, with optional line range (try it in visual mode!). Plugins
40 are available for popular providers such as [GitHub][rhubarb.vim],
41 [GitLab][fugitive-gitlab.vim], and [Bitbucket][fubitive.vim].
43 [rhubarb.vim]: https://github.com/tpope/vim-rhubarb
44 [fugitive-gitlab.vim]: https://github.com/shumphrey/fugitive-gitlab.vim
45 [fubitive.vim]: https://github.com/tommcdo/vim-fubitive
47 Add `%{FugitiveStatusline()}` to `'statusline'` to get an indicator
48 with the current branch in (surprise!) your statusline.
50 Last but not least, there's `:Git` for running any arbitrary command,
51 and `Git!` to open the output of a command in a temp file.
55 * [A complement to command line git](http://vimcasts.org/e/31)
56 * [Working with the git index](http://vimcasts.org/e/32)
57 * [Resolving merge conflicts with vimdiff](http://vimcasts.org/e/33)
58 * [Browsing the git object database](http://vimcasts.org/e/34)
59 * [Exploring the history of a git repository](http://vimcasts.org/e/35)
63 If you don't have a preferred installation method, one option is to install
64 [pathogen.vim](https://github.com/tpope/vim-pathogen), and then copy
68 git clone https://github.com/tpope/vim-fugitive.git
69 vim -u NONE -c "helptags vim-fugitive/doc" -c q
71 If your Vim version is below 7.2, I recommend also installing
72 [vim-git](https://github.com/tpope/vim-git) for syntax highlighting and
77 > Why don't any of the commands exist?
79 Fugitive cares about the current file, not the current working directory.
80 Edit a file from the repository. To avoid the blank window problem, favor
81 commands like `:split` and `:tabedit` over commands like `:new` and `:tabnew`.
83 > Here's a patch that automatically opens the quickfix window after
86 This is a great example of why I recommend asking before patching.
87 There are valid arguments to be made both for and against automatically
88 opening the quickfix window. Whenever I have to make an arbitrary
89 decision like this, I ask what Vim would do. And Vim does not open a
90 quickfix window after `:grep`.
92 Luckily, it's easy to implement the desired behavior without changing
93 fugitive.vim. The following autocommand will cause the quickfix window
94 to open after any grep invocation:
96 autocmd QuickFixCmdPost *grep* cwindow
100 Like fugitive.vim? Follow the repository on
101 [GitHub](https://github.com/tpope/vim-fugitive) and vote for it on
102 [vim.org](http://www.vim.org/scripts/script.php?script_id=2975). And if
103 you're feeling especially charitable, follow [tpope](http://tpo.pe/) on
104 [Twitter](http://twitter.com/tpope) and
105 [GitHub](https://github.com/tpope).
109 Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.