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)
42 cA |:Gcommit| --amend --reuse-message=HEAD
45 cva |:Gcommit| --amend --verbose
46 cvc |:Gcommit| --verbose
49 dp |:Git!| diff (p for patch; use :Gw to apply)
50 dp |:Git| add --intent-to-add (untracked files)
55 p |:Git| reset --patch (staged files)
61 :Gcommit [args] A wrapper around git-commit. If there is nothing
62 to commit, |:Gstatus| is called instead. Unless the
63 arguments given would skip the invocation of an editor
64 (e.g., -m), a split window will be used to obtain a
65 commit message. Write and close that window (:wq or
66 |:Gwrite|) to finish the commit. Unlike when running
67 the actual git-commit command, it is possible (but
68 unadvisable) to muck with the index with commands like
69 git-add and git-reset while a commit message is
73 :Ggrep [args] |:grep| with git-grep as 'grepprg'.
76 :Glgrep [args] |:lgrep| with git-grep as 'grepprg'.
79 :Glog [args] Load all previous revisions of the current file into
80 the quickfix list. Additional git-log arguments can
81 be given (for example, --reverse). If "--" appears as
82 an argument, no file specific filtering is done, and
83 previous commits rather than previous file revisions
87 :Gllog [args] Like |:Glog|, but use the location list instead of the
90 *fugitive-:Gedit* *fugitive-:Ge*
91 :Gedit [revision] |:edit| a |fugitive-revision|.
94 :Gsplit [revision] |:split| a |fugitive-revision|.
97 :Gvsplit [revision] |:vsplit| a |fugitive-revision|.
100 :Gtabedit [revision] |:tabedit| a |fugitive-revision|.
103 :Gpedit [revision] |:pedit| a |fugitive-revision|.
105 :Gsplit! [args] *fugitive-:Gsplit!* *fugitive-:Gvsplit!*
106 :Gvsplit! [args] *fugitive-:Gtabedit!* *fugitive-:Gpedit!*
107 :Gtabedit! [args] Like |:Git!|, but open the resulting temp file in a
108 :Gpedit! [args] split, tab, or preview window.
111 :Gread [revision] Empty the buffer and |:read| a |fugitive-revision|.
112 When the argument is omitted, this is similar to
113 git-checkout on a work tree file or git-add on a stage
114 file, but without writing anything to disk.
116 :{range}Gread [revision]
117 |:read| in a |fugitive-revision| after {range}.
120 :Gread! [args] Empty the buffer and |:read| the output of a Git
121 command. For example, :Gread! show HEAD:%.
123 :{range}Gread! [args] |:read| the output of a Git command after {range}.
126 :Gwrite Write to the current file's path and stage the results.
127 When run in a work tree file, it is effectively git
128 add. Elsewhere, it is effectively git-checkout. A
129 great deal of effort is expended to behave sensibly
130 when the work tree or index version of the file is
131 open in another buffer.
133 :Gwrite {path} You can give |:Gwrite| an explicit path of where in
134 the work tree to write. You can also give a path like
135 :0:foo.txt or even :0 to write to just that stage in
139 :Gwq [path] Like |:Gwrite| followed by |:quit| if the write
142 :Gwq! [path] Like |:Gwrite|! followed by |:quit|! if the write
146 :Gdiff [revision] Perform a |vimdiff| against the current file in the
147 given revision. With no argument, the version in the
148 index is used (which means a three-way diff during a
149 merge conflict, making it a git-mergetool
150 alternative). The newer of the two files is placed
151 to the right. Use |do| and |dp| and write to the
152 index file to simulate "git add --patch".
155 :Gsdiff [revision] Like |:Gdiff|, but split horizontally.
158 :Gvdiff [revision] Identical to |:Gdiff|. For symmetry with |:Gsdiff|.
161 :Gmove {destination} Wrapper around git-mv that renames the buffer
162 afterward. The destination is relative to the current
163 directory except when started with a /, in which case
164 it is relative to the work tree. Add a ! to pass -f.
167 :Gremove Wrapper around git-rm that deletes the buffer
168 afterward. When invoked in an index file, --cached is
169 passed. Add a ! to pass -f and forcefully discard the
173 :Gblame [flags] Run git-blame on the file and open the results in a
174 scroll bound vertical split. Press enter on a line to
175 reblame the file as it was in that commit. You can
176 give any of ltfnsewMC as flags and they will be passed
177 along to git-blame. The following maps, which work on
178 the cursor line commit where sensible, are provided:
180 A resize to end of author column
181 C resize to end of commit column
182 D resize to end of date/time column
183 q close blame and return to blamed window
184 gq q, then |:Gedit| to return to work tree version
185 i q, then open commit
186 o open commit in horizontal split
187 O open commit in new tab
189 ~ reblame at [count]th first grandparent
190 P reblame at [count]th parent (like HEAD^[count])
192 :[range]Gblame [flags] Run git-blame on the given range.
195 :[range]Gbrowse If the remote for the current branch is on GitHub,
196 open the current file, blob, tree, commit, or tag
197 (with git-web--browse) on GitHub. Otherwise, open the
198 current file, blob, tree, commit, or tag in
199 git-instaweb (if you have issues, verify you can run
200 "git instaweb" from a terminal). If a range is given,
201 it is appropriately appended to the URL as an anchor.
203 To use with GitHub FI, point g:fugitive_github_domains
204 at a list of domains:
206 let g:fugitive_github_domains = ['git.example.com']
208 :[range]Gbrowse! Like :Gbrowse, but put the URL on the clipboard rather
211 :[range]Gbrowse {revision}
212 Like :Gbrowse, but for a given |fugitive-revision|. A
213 useful value here is -, which ties the URL to the
214 latest commit rather than a volatile branch.
216 :[range]Gbrowse [...]@{remote}
217 Force using the given remote rather than the remote
218 for the current branch. The remote is used to
219 determine which GitHub repository to link to.
221 MAPPINGS *fugitive-mappings*
223 These maps are available everywhere.
225 *fugitive-c_CTRL-R_CTRL-G*
226 <C-R><C-G> On the command line, recall the path to the current
227 object (that is, a representation of the object
228 recognized by |:Gedit|).
231 ["x]y<C-G> Yank the commit SHA and path to the current object.
233 These maps are available in Git objects.
236 <CR> Jump to the revision under the cursor.
239 o Jump to the revision under the cursor in a new split.
242 S Jump to the revision under the cursor in a new
246 O Jump to the revision under the cursor in a new tab.
249 - Go to the tree containing the current tree or blob.
252 ~ Go to the current file in the [count]th first
256 P Go to the current file in the [count]th parent.
259 C Go to the commit containing the current file.
262 a Show the current tag, commit, or tree in an alternate
265 SPECIFYING REVISIONS *fugitive-revision*
267 Fugitive revisions are similar to Git revisions as defined in the "SPECIFYING
268 REVISIONS" section in the git-rev-parse man page. For commands that accept an
269 optional revision, the default is the file in the index for work tree files
270 and the work tree file for everything else. Example revisions follow.
274 master .git/refs/heads/master
275 HEAD^{} The commit referenced by HEAD
276 HEAD^ The parent of the commit referenced by HEAD
277 HEAD: The tree referenced by HEAD
278 /HEAD The file named HEAD in the work tree
279 Makefile The file named Makefile in the work tree
280 HEAD^:Makefile The file named Makefile in the parent of HEAD
281 :Makefile The file named Makefile in the index (writable)
282 - The current file in HEAD
283 ^ The current file in the previous commit
284 ~3 The current file 3 commits ago
285 : .git/index (Same as |:Gstatus|)
286 :0 The current file in the index
287 :1 The current file's common ancestor during a conflict
288 :2 The current file in the target branch during a conflict
289 :3 The current file in the merged branch during a conflict
290 :/foo The most recent commit with "foo" in the message
292 STATUSLINE *fugitive-statusline*
294 *fugitive#statusline()*
295 Add %{fugitive#statusline()} to your statusline to get an indicator including
296 the current branch and the currently edited file's commit. If you don't have
297 a statusline, this one matches the default when 'ruler' is set:
299 set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
302 Use fugitive#head() to return the name of the current branch. If the current
303 HEAD is detached, fugitive#head() will return the empty string, unless the
304 optional argument is given, in which case the hash of the current commit will
305 be truncated to the given number of characters.
307 ABOUT *fugitive-about*
309 Grab the latest version or report a bug on GitHub:
311 http://github.com/tpope/vim-fugitive
313 vim:tw=78:et:ft=help:norl: