1 *fugitive.txt* A Git wrapper so awesome, it should be illegal
3 Author: Tim Pope <http://tpo.pe/>
4 License: Same terms as Vim itself (see |license|)
6 This plugin is only available if 'compatible' is not set.
8 INTRODUCTION *fugitive*
10 Whenever you edit a file from a Git repository, a set of commands is defined
11 that serve as a gateway to Git.
13 COMMANDS *fugitive-commands*
15 These commands are local to the buffers in which they work (generally, buffers
16 that are part of Git repositories).
19 :Git [args] Run an arbitrary git command. Similar to :!git [args]
20 but chdir to the repository tree first.
23 :Git! [args] Like |:Git|, but capture the output into a temp file,
24 and edit that temp file.
27 :Gcd [directory] |:cd| relative to the repository.
30 :Glcd [directory] |:lcd| relative to the repository.
33 :Gstatus Bring up the output of git-status in the preview
34 window. The following maps, which work on the cursor
35 line file where sensible, are provided:
41 - |:Git| reset (staged files)
43 cA |Gcommit| --amend --reuse-message=HEAD
47 dp |:Git!| diff (p for patch; use :Gw to apply)
48 dp |:Git| add --intent-to-add (untracked files)
53 p |:Git| reset --patch (staged files)
58 :Gcommit [args] A wrapper around git-commit. If there is nothing
59 to commit, |:Gstatus| is called instead. Unless the
60 arguments given would skip the invocation of an editor
61 (e.g., -m), a split window will be used to obtain a
62 commit message. Write and close that window (:wq or
63 |:Gwrite|) to finish the commit. Unlike when running
64 the actual git-commit command, it is possible (but
65 unadvisable) to muck with the index with commands like
66 git-add and git-reset while a commit message is
70 :Ggrep [args] |:grep| with git-grep as 'grepprg'.
73 :Glog [args] Load all previous revisions of the current file into
74 the quickfix list. Additional git-log arguments can
75 be given (for example, --reverse). If "--" appears as
76 an argument, no file specific filtering is done, and
77 commits are loaded into the quickfix list.
79 *fugitive-:Gedit* *fugitive-:Ge*
80 :Gedit [revision] |:edit| a |fugitive-revision|.
83 :Gsplit [revision] |:split| a |fugitive-revision|.
86 :Gvsplit [revision] |:vsplit| a |fugitive-revision|.
89 :Gtabedit [revision] |:tabedit| a |fugitive-revision|.
92 :Gpedit [revision] |:pedit| a |fugitive-revision|.
94 :Gsplit! [args] *fugitive-:Gsplit!* *fugitive-:Gvsplit!*
95 :Gvsplit! [args] *fugitive-:Gtabedit!* *fugitive-:Gpedit!*
96 :Gtabedit! [args] Like |:Git!|, but open the resulting temp file in a
97 :Gpedit! [args] split, tab, or preview window.
100 :Gread [revision] Empty the buffer and |:read| a |fugitive-revision|.
101 When the argument is omitted, this is similar to
102 git-checkout on a work tree file or git-add on a stage
103 file, but without writing anything to disk.
105 :{range}Gread [revision]
106 |:read| in a |fugitive-revision| after {range}.
109 :Gread! [args] Empty the buffer and |:read| the output of a Git
110 command. For example, :Gread! show HEAD:%.
112 :{range}Gread! [args] |:read| the output of a Git command after {range}.
115 :Gwrite Write to the current file's path and stage the results.
116 When run in a work tree file, it is effectively git
117 add. Elsewhere, it is effectively git-checkout. A
118 great deal of effort is expended to behave sensibly
119 when the work tree or index version of the file is
120 open in another buffer.
122 :Gwrite {path} You can give |:Gwrite| an explicit path of where in
123 the work tree to write. You can also give a path like
124 :0:foo.txt or even :0 to write to just that stage in
128 :Gwq [path] Like |:Gwrite| followed by |:quit| if the write
131 :Gwq! [path] Like |:Gwrite|! followed by |:quit|! if the write
135 :Gdiff [revision] Perform a |vimdiff| against the current file in the
136 given revision. With no argument, the version in the
137 index is used (which means a three-way diff during a
138 merge conflict, making it a git-mergetool
139 alternative). The newer of the two files is placed
140 to the right. Use |do| and |dp| and write to the
141 index file to simulate "git add --patch".
144 :Gsdiff [revision] Like |:Gdiff|, but split horizontally.
147 :Gvdiff [revision] Identical to |:Gdiff|. For symmetry with |:Gsdiff|.
150 :Gmove {destination} Wrapper around git-mv that renames the buffer
151 afterward. The destination is relative to the current
152 directory except when started with a /, in which case
153 it is relative to the work tree. Add a ! to pass -f.
156 :Gremove Wrapper around git-rm that deletes the buffer
157 afterward. When invoked in an index file, --cached is
158 passed. Add a ! to pass -f and forcefully discard the
162 :Gblame [flags] Run git-blame on the file and open the results in a
163 scroll bound vertical split. Press enter on a line to
164 reblame the file as it was in that commit. You can
165 give any of ltwfsMC as flags and they will be passed
168 In a blame buffer on any line, one can press <CR> to
169 reblame at that commit, ~ to reblame at that commit's
170 [count]th first grandparent (like HEAD~[count]), or P
171 to reblame at that commit's [count]th parent (like
172 HEAD^[count]). Press o or O to open up that commit
173 in a horizontal of vertical split. Pressing q will
174 close the blame buffer.
176 :[range]Gblame [flags] Run git-blame on the given range.
179 :[range]Gbrowse If the remote for the current branch is on GitHub,
180 open the current file, blob, tree, commit, or tag
181 (with git-web--browse) on GitHub. Otherwise, open the
182 current file, blob, tree, commit, or tag in
183 git-instaweb (if you have issues, verify you can run
184 "git instaweb" from a terminal). If a range is given,
185 it is appropriately appended to the URL as an anchor.
187 :[range]Gbrowse! Like :Gbrowse, but put the URL on the clipboard rather
190 :[range]Gbrowse {revision}
191 Like :Gbrowse, but for a given |fugitive-revision|. A
192 useful value here is -, which ties the URL to the
193 latest commit rather than a volatile branch.
195 :[range]Gbrowse [...]@{remote}
196 Force using the given remote rather than the remote
197 for the current branch. The remote is used to
198 determine which GitHub repository to link to.
200 MAPPINGS *fugitive-mappings*
202 These maps are available in Git objects.
205 <CR> Jump to the revision under the cursor.
208 o Jump to the revision under the cursor in a new split.
211 O Jump to the revision under the cursor in a new tab.
214 ~ Go to the current file in the [count]th first
218 P Go to the current file in the [count]th parent.
221 C Go to the commit containing the current file.
224 a Show the current tag, commit, or tree in an alternate
227 SPECIFYING REVISIONS *fugitive-revision*
229 Fugitive revisions are similar to Git revisions as defined in the "SPECIFYING
230 REVISIONS" section in the git-rev-parse man page. For commands that accept an
231 optional revision, the default is the file in the index for work tree files
232 and the work tree file for everything else. Example revisions follow.
236 master .git/refs/heads/master
237 HEAD^{} The commit referenced by HEAD
238 HEAD^ The parent of the commit referenced by HEAD
239 HEAD: The tree referenced by HEAD
240 /HEAD The file named HEAD in the work tree
241 Makefile The file named Makefile in the work tree
242 HEAD^:Makefile The file named Makefile in the parent of HEAD
243 :Makefile The file named Makefile in the index (writable)
244 - The current file in HEAD
245 ^ The current file in the previous commit
246 ~3 The current file 3 commits ago
247 : .git/index (Same as |:Gstatus|)
248 :0 The current file in the index
249 :1 The current file's common ancestor during a conflict
250 :2 The current file in the target branch during a conflict
251 :3 The current file in the merged branch during a conflict
252 :/foo The most recent commit with "foo" in the message
254 STATUSLINE *fugitive-statusline*
256 *fugitive#statusline()*
257 Add %{fugitive#statusline()} to your statusline to get an indicator including
258 the current branch and the currently edited file's commit. If you don't have
259 a statusline, this one matches the default when 'ruler' is set:
261 set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
263 ABOUT *fugitive-about*
265 Grab the latest version or report a bug on GitHub:
267 http://github.com/tpope/vim-fugitive
269 vim:tw=78:et:ft=help:norl: