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. `:Gremove` 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 GitHub, with optional line
39 range (try it in visual mode!). If your current repository isn't on
40 GitHub, `git instaweb` will be spun up instead.
42 Add `%{fugitive#statusline()}` to `'statusline'` to get an indicator
43 with the current branch in (surprise!) your statusline.
45 Last but not least, there's `:Git` for running any arbitrary command,
46 and `Git!` to open the output of a command in a temp file.
50 * [A complement to command line git](http://vimcasts.org/e/31)
51 * [Working with the git index](http://vimcasts.org/e/32)
52 * [Resolving merge conflicts with vimdiff](http://vimcasts.org/e/33)
53 * [Browsing the git object database](http://vimcasts.org/e/34)
54 * [Exploring the history of a git repository](http://vimcasts.org/e/35)
58 If you don't have a preferred installation method, one option is to install
59 [pathogen.vim](https://github.com/tpope/vim-pathogen), and then copy
63 git clone git://github.com/tpope/vim-fugitive.git
64 vim -u NONE -c "helptags vim-fugitive/doc" -c q
66 If your Vim version is below 7.2, I recommend also installing
67 [vim-git](https://github.com/tpope/vim-git) for syntax highlighting and
72 > I installed the plugin and started Vim. Why don't any of the commands
75 Fugitive cares about the current file, not the current working
76 directory. Edit a file from the repository.
78 > I opened a new tab. Why don't any of the commands exist?
80 Fugitive cares about the current file, not the current working
81 directory. Edit a file from the repository.
83 > Why is `:Gbrowse` not using the right browser?
85 `:Gbrowse` delegates to `git web--browse`, which is less than perfect
86 when it comes to finding the right browser. You can tell it the correct
87 browser to use with `git config --global web.browser ...`. On OS X, for
88 example, you might want to set this to `open`. See `git web--browse --help`
91 > Here's a patch that automatically opens the quickfix window after
94 This is a great example of why I recommend asking before patching.
95 There are valid arguments to be made both for and against automatically
96 opening the quickfix window. Whenever I have to make an arbitrary
97 decision like this, I ask what Vim would do. And Vim does not open a
98 quickfix window after `:grep`.
100 Luckily, it's easy to implement the desired behavior without changing
101 fugitive.vim. The following autocommand will cause the quickfix window
102 to open after any grep invocation:
104 autocmd QuickFixCmdPost *grep* cwindow
108 Like fugitive.vim? Follow the repository on
109 [GitHub](https://github.com/tpope/vim-fugitive) and vote for it on
110 [vim.org](http://www.vim.org/scripts/script.php?script_id=2975). And if
111 you're feeling especially charitable, follow [tpope](http://tpo.pe/) on
112 [Twitter](http://twitter.com/tpope) and
113 [GitHub](https://github.com/tpope).
117 Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.