1 *fugitive.txt* A Git wrapper so awesome, it should be illegal
3 Author: Tim Pope <vimNOSPAM@tpope.org> *fugitive-author*
4 License: Same terms as Vim itself (see |license|)
6 This plugin is only available if 'compatible' is not set.
8 INTRODUCTION *fugitive*
10 Install in ~/.vim, or in ~\vimfiles if you're on Windows and feeling lucky.
11 Vim 7.2 is recommended as it ships with syntax highlighting for many Git file
14 If you're in a hurry to get started, here are some things to try:
16 In any file in your repository, run |:Gedit| HEAD. Press <CR> to jump to the
17 current branch. Press <CR> again to jump to the top most commit. Keep using
18 <CR> to explore parent commits, trees, and blobs. Use C in a tree or blob to
19 get back to the commit.
21 Edit a file in the work tree and make some changes. Use |:Gdiff| to open up
22 the indexed version. Use |do| and |dp| on various hunks to bring the files in
23 sync, or use |:Gread| to pull in all changes. Write the indexed version to
26 Run |:Gstatus| to check your repository's status. Use "-" to stage and reset
27 files and "p" to add/reset --patch them. Invoke |:Gcommit| to commit your
30 Run |:Gblame| in a work tree file to see a blame in a vertical split. Press
31 <CR> on any line to reopen and reblame that file as it stood in that commit.
32 Press o or O on any line to inspect that commit in a split or a tab.
34 Run |:Ggrep| to search the work tree or history. Run |:Gmove| to rename a
35 file. Run |:Gremove| to delete a file.
37 COMMANDS *fugitive-commands*
39 These commands are local to the buffers in which they work (generally, buffers
40 that are part of Git repositories).
43 :Git [args] Run an arbitrary git command. Similar to :!git [args]
44 but chdir to the repository tree first.
47 :Gcd [directory] |:cd| relative to the repository.
50 :Glcd [directory] |:lcd| relative to the repository.
53 :Gstatus Bring up the output of git-status in the preview
54 window. In addition to standard motions, you can
55 use <C-N> and <C-P> to jump from filename to
56 filename. Press C to invoke |:Gcommit|. Press D to
57 |:Gdiff| the file on the cursor line, or ds to
58 |:Gsdiff|. Press - to stage or unstage the file on
59 the cursor line. Press p to do so on a per hunk basis
60 (--patch). All of D, -, and p have a different,
61 sensible (and hopefully intuitive) behavior when
62 invoked on a heading rather than a file name.
65 :Gcommit [args] A wrapper around git-commit. If there is nothing
66 to commit, |:Gstatus| is called instead. Unless the
67 arguments given would skip the invocation of an editor
68 (e.g., -m), a split window will be used to obtain a
69 commit message. Write and close that window (:wq or
70 |:Gwrite|) to finish the commit. Unlike when running
71 the actual git-commit command, it is possible (but
72 unadvisable) to muck with the index with commands like
73 git-add and git-reset while a commit message is
77 :Ggrep [args] |:grep| with git-grep as 'grepprg'.
80 :Glog [args] Load all previous revisions of the current file into
81 the quickfix list. Additional git-log arguments can
82 be given (for example, --reverse). If "--" appears as
83 an argument, no file specific filtering is done, and
84 commits are loaded into the quickfix list.
86 *fugitive-:Gedit* *fugitive-:Ge*
87 :Gedit [revision] |:edit| a |fugitive-revision|.
90 :Gsplit [revision] |:split| a |fugitive-revision|.
93 :Gvsplit [revision] |:vsplit| a |fugitive-revision|.
96 :Gtabedit [revision] |:tabedit| a |fugitive-revision|
99 :Gpedit [revision] |:pedit| a |fugitive-revision|
102 :Gread [revision] Empty the buffer and |:read| a |fugitive-revision|.
103 When the argument is omitted, this is similar to
104 git-checkout on a work tree file or git-add on a stage
105 file, but without writing anything to disk.
107 :{range}Gread [revision]
108 |:read| in a |fugitive-revision| after {range}.
111 :Gwrite Write to the current file's path and stage the results.
112 When run in a work tree file, it is effectively git
113 add. Elsewhere, it is effectively git-checkout. A
114 great deal of effort is expended to behave sensibly
115 when the work tree or index version of the file is
116 open in another buffer.
118 :Gwrite {path} You can give |:Gwrite| an explicit path of where in
119 the work tree to write. You can also give a path like
120 :0:foo.txt or even :0 to write to just that stage in
124 :Gwq [path] Like |:Gwrite| followed by |:quit| if the write
127 :Gwq! [path] Like |:Gwrite|! followed by |:quit|! if the write
131 :Gdiff [revision] Perform a |vimdiff| against the current file in the
132 given revision. With no argument, the version in the
133 index is used (which means a three-way diff during a
134 merge conflict, making it a git-mergetool
135 alternative). The newer of the two files is placed
136 to the right. Use |do| and |dp| and write to the
137 index file to simulate "git add --patch".
140 :Gsdiff [revision] Like |:Gdiff|, but split horizontally.
143 :Gvdiff [revision] Identical to |:Gdiff|. For symmetry with |:Gsdiff|.
146 :Gmove {destination} Wrapper around git-mv that renames the buffer
147 afterward. The destination is relative to the current
148 directory except when started with a /, in which case
149 it is relative to the work tree. Add a ! to pass -f.
152 :Gremove Wrapper around git-rm that deletes the buffer
153 afterward. When invoked in an index file, --cached is
154 passed. Add a ! to pass -f and forcefully discard the
158 :Gblame [flags] Run git-blame on the file and open the results in a
159 scroll bound vertical split. Press enter on a line to
160 reblame the file as it was in that commit. You can
161 give any of ltwfsMC as flags and they will be passed
164 :[range]Gblame [flags] Run git-blame on the given range.
167 :[range]Gbrowse If the remote for the current branch is on GitHub,
168 open the current file, blob, tree, commit, or tag
169 (with git-web--browse) on GitHub. Otherwise, open the
170 current file, blob, tree, commit, or tag in
171 git-instaweb (if you have issues, verify you can run
172 "git instaweb" from a terminal). If a range is given,
173 it is appropriately appended to the URL as an anchor.
175 :[range]Gbrowse! Like :Gbrowse, but put the URL on the clipboard rather
178 :[range]Gbrowse {revision}
179 Like :Gbrowse, but for a given |fugitive-revision|. A
180 useful value here is -, which ties the URL to the
181 latest commit rather than a volatile branch.
183 :[range]Gbrowse [...]@{remote}
184 Force using the given remote rather than the remote
185 for the current branch. The remote is used to
186 determine which GitHub repository to link to.
188 MAPPINGS *fugitive-mappings*
190 These maps are available in Git objects.
193 <CR> Jump to the revision under the cursor.
196 o Jump to the revision under the cursor in a new split.
199 O Jump to the revision under the cursor in a new tab.
202 ~ Go to the current file in the [count]th first
206 P Go to the current file in the [count]th parent.
209 C Go to the commit containing the current file.
212 a Show the current tag, commit, or tree in an alternate
215 SPECIFYING REVISIONS *fugitive-revision*
217 Fugitive revisions are similar to Git revisions as defined in the "SPECIFYING
218 REVISIONS" section in the git-rev-parse man page. For commands that accept an
219 optional revision, the default is the file in the index for work tree files
220 and the work tree file for everything else. Example revisions follow.
224 master .git/refs/heads/master
225 HEAD^{} The commit referenced by HEAD
226 HEAD^ The parent of the commit referenced by HEAD
227 HEAD: The tree referenced by HEAD
228 /HEAD The file named HEAD in the work tree
229 Makefile The file named Makefile in the work tree
230 HEAD^:Makefile The file named Makefile in the parent of HEAD
231 :Makefile The file named Makefile in the index (writable)
232 - The current file in HEAD
233 ^ The current file in the previous commit
234 ~3 The current file 3 commits ago
235 : .git/index (Same as |:Gstatus|)
236 :0 The current file in the index
237 :1 The current file's common ancestor during a conflict
238 :2 The current file in the target branch during a conflict
239 :3 The current file in the merged branch during a conflict
240 :/foo The most recent commit with "foo" in the message
242 STATUSLINE *fugitive-statusline*
244 *fugitive#statusline()*
245 Add %{fugitive#statusline()} to your statusline to get an indicator including
246 the current branch and the currently edited file's commit. If you don't have
247 a statusline, this one matches the default when 'ruler' is set:
249 set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
251 ABOUT *fugitive-about*
253 Grab the latest version or report a bug on GitHub:
255 http://github.com/tpope/vim-fugitive
257 vim:tw=78:et:ft=help:norl: