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` that
15 mofo. And guess what `:Gcommit` does!
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, I recommend
59 installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and
60 then simply copy and paste:
63 git clone git://github.com/tpope/vim-fugitive.git
65 Once help tags have been generated, you can view the manual with
68 If your Vim version is below 7.2, I recommend also installing
69 [vim-git](https://github.com/tpope/vim-git) for syntax highlighting and
74 > I installed the plugin and started Vim. Why don't any of the commands
77 Fugitive cares about the current file, not the current working
78 directory. Edit a file from the repository.
80 > I opened a new tab. Why don't any of the commands exist?
82 Fugitive cares about the current file, not the current working
83 directory. Edit a file from the repository.
85 > Why is `:Gbrowse` not using the right browser?
87 `:Gbrowse` delegates to `git web--browse`, which is less than perfect
88 when it comes to finding the right browser. You can tell it the correct
89 browser to use with `git config --global web.browser ...`. On OS X, for
90 example, you might want to set this to `open`. See `git web--browse --help`
93 > Here's a patch that automatically opens the quickfix window after
96 This is a great example of why I recommend asking before patching.
97 There are valid arguments to be made both for and against automatically
98 opening the quickfix window. Whenever I have to make an arbitrary
99 decision like this, I ask what Vim would do. And Vim does not open a
100 quickfix window after `:grep`.
102 Luckily, it's easy to implement the desired behavior without changing
103 fugitive.vim. The following autocommand will cause the quickfix window
104 to open after any grep invocation:
106 autocmd QuickFixCmdPost *grep* cwindow
110 Like fugitive.vim? Follow the repository on
111 [GitHub](https://github.com/tpope/vim-fugitive) and vote for it on
112 [vim.org](http://www.vim.org/scripts/script.php?script_id=2975). And if
113 you're feeling especially charitable, follow [tpope](http://tpo.pe/) on
114 [Twitter](http://twitter.com/tpope) and
115 [GitHub](https://github.com/tpope).
119 Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.