Document disabling global maps
[vim-fugitive.git] / doc / fugitive.txt
blob999bfdf1226242c8f8123de72f2bc02d8e6586d8
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).
18                                                 *:Git* *fugitive-:G*
19 :Git {args}             Run an arbitrary git command. Similar to :!git [args]
20 :G {args}               but chdir to the repository tree first.  For some
21                         subcommands, a Fugitive command is called instead.
23                                                 *:Git!*
24 :Git! {args}            Like |:Git|, but capture the output into a temp file,
25 :Git --no-pager {args}  and |:split| that temp file.  Use :0Git to
26 :Git -P {args}          |:edit| the temp file instead.  A temp file is always
27                         used for diff and log commands.
29                                                 *:Gstatus*
30 :Git                    Bring up a summary window vaguely akin to git-status.
31 :G                      Press g? or see |fugitive-maps| for usage.
32 :Gstatus
34                                                 *:Git-commit* *:Gcommit*
35 :Git commit [args]      A wrapper around git-commit.  Unless the arguments
36 :Gcommit [args]         given would skip the invocation of an editor (e.g.,
37                         -m), a split window will be used to obtain a commit
38                         message, or a new tab if -v is given.  Write and close
39                         the window (:wq) to finish the commit. To cancel, use
40                         an empty message.
42                                                 *:Git-revert* *:Grevert*
43 :Git revert [args]      A wrapper around git-revert.  Similar to |:Gcommit|.
44 :Grevert [args]
46                                                 *:Git-merge* *:Gmerge*
47 :Git merge [args]       Calls git-merge and loads errors and conflicted files
48 :Gmerge [args]          into the |quickfix| list.  Opens a |:Gcommit| style
49                         split window for the commit message if the merge
50                         succeeds.  If called during a merge conflict, the
51                         conflicted files from the current index are loaded
52                         into the |quickfix| list.
54                                                 *:Git-pull* *:Gpull*
55 :Git pull [args]        Like |:Gmerge|, but for git-pull.
56 :Gpull [args]
58                                                 *:Git-rebase* *:Grebase*
59 :Git rebase [args]      Like |:Gmerge|, but for git-rebase.  Interactive
60 :Grebase [args]         rebase is experimentally supported.
62                                                 *:Git-push* *:Gpush*
63 :Git push [args]        Invoke git-push, load the results into the |quickfix|
64 :Gpush [args]           list, and invoke |:cwindow| to reveal any errors.
65                         |:Dispatch| is used if available for asynchronous
66                         invocation.
68                                                 *:Git-fetch* *:Gfetch*
69 :Git fetch [args]       Like |:Gpush|, but for git-fetch.
70 :Gfetch [args]
72                                                 *:Git-blame* *:Gblame*
73 :Git blame [flags]      Run git-blame [flags] on the current file and open the
74 :Gblame [flags]         results in a scroll-bound vertical split.  The
75                         following maps, which work on the cursor line commit
76                         where sensible, are provided:
78                         g?    show this help
79                         A     resize to end of author column
80                         C     resize to end of commit column
81                         D     resize to end of date/time column
82                         gq    close blame, then |:Gedit| to return to work
83                               tree version
84                         <CR>  close blame, and jump to patch that added line
85                               (or directly to blob for boundary commit)
86                         o     jump to patch or blob in horizontal split
87                         O     jump to patch or blob in new tab
88                         p     jump to patch or blob in preview window
89                         -     reblame at commit
90                         ~     reblame at [count]th first grandparent
91                         P     reblame at [count]th parent (like HEAD^[count])
93 :[range]Gblame [flags]  If a range is given, just that part of the file will
94 :Gblame [flags] {file}  be blamed, and a horizontal split without
95 :Git blame ...          scrollbinding is used.  You can also give an arbitrary
96                         filename.
98                                                 *:Ggrep* *:Gcgrep* *:Git-grep*
99 :Ggrep[!] [args]        |:grep|[!] with git-grep as 'grepprg'.
100 :Git[!] grep [args]
102                                                 *:Glgrep*
103 :Glgrep[!] [args]       |:lgrep|[!] with git-grep as 'grepprg'.
104 :0Git[!] grep [args]
106                                                  *:Gclog* *:Glog*
107 :Gclog[!] [args]        Use git-log [args] to load the commit history into the
108 :Glog[!] [args]         |quickfix| list.  Jump to the first commit unless [!]
109                         is given.
111 :{range}Gclog[!] [args] Use git-log -L to load previous revisions of the given
112                         range of the current file into the |quickfix| list.
113                         The cursor is positioned on the first line of the
114                         first diff hunk for each commit.  Use :0Gclog to
115                         target the entire file.
117                                                 *:Gllog*
118 :Gllog [args]           Like |:Gclog|, but use the location list instead of the
119                         |quickfix| list.
121                                                 *:Gcd*
122 :Gcd [directory]        |:cd| relative to the repository.
124                                                 *:Glcd*
125 :Glcd [directory]       |:lcd| relative to the repository.
127                                                 *:Gedit* *fugitive-:Ge*
128 :Gedit [object]         |:edit| a |fugitive-object|.
130                                                 *:Gsplit*
131 :Gsplit [object]        |:split| a |fugitive-object|.
133                                                 *:Gvsplit*
134 :Gvsplit [object]       |:vsplit| a |fugitive-object|.
136                                                 *:Gtabedit*
137 :Gtabedit [object]      |:tabedit| a |fugitive-object|.
139                                                 *:Gpedit*
140 :Gpedit [object]        |:pedit| a |fugitive-object|.
142 :Gsplit! [args]                                 *:Gsplit!* *:Gvsplit!*
143 :Gvsplit! [args]                                *:Gtabedit!* *:Gpedit!*
144 :Gtabedit! [args]       Capture the output of `git [args]` to a temp file and
145 :Gpedit! [args]         open it in a split, tab, or preview window.  Use
146                         :0Gsplit! to suppress the split and open it in the
147                         current window.
149                                                 *:Gread* *fugitive-:Gr*
150 :Gread [object]         Empty the buffer and |:read| a |fugitive-object|.
151                         When the argument is omitted, this is similar to
152                         git-checkout on a work tree file or git-add on a stage
153                         file, but without writing anything to disk.
155 :{range}Gread [object]  |:read| in a |fugitive-object| after {range}.
157                                                 *:Gread!* *fugitive-:Gr!*
158 :Gread! [args]          Empty the buffer and |:read| the output of a Git
159                         command.  For example, :Gread! show HEAD:%.
161 :{range}Gread! [args]   |:read| the output of a Git command after {range}.
163                                                 *:Gwrite* *fugitive-:Gw*
164 :Gwrite                 Write to the current file's path and stage the results.
165                         When run in a work tree file, it is effectively git
166                         add.  Elsewhere, it is effectively git-checkout.  A
167                         great deal of effort is expended to behave sensibly
168                         when the work tree or index version of the file is
169                         open in another buffer.
171 :Gwrite {path}          You can give |:Gwrite| an explicit path of where in
172                         the work tree to write.  You can also give a path like
173                         :0:foo.txt or :0:% to write to just that stage in
174                         the index.
176                                                 *:Gwq*
177 :Gwq [path]             Like |:Gwrite| followed by |:quit| if the write
178                         succeeded.
180 :Gwq! [path]            Like |:Gwrite|! followed by |:quit|! if the write
181                         succeeded.
183                                                 *:Gdiffsplit*
184 :Gdiffsplit [object]    Perform a |vimdiff| against the given file, or if a
185                         commit is given, the current file in that commit.
186                         With no argument, the version in the index or work
187                         tree is used.  The newer of the two files is placed to
188                         the right or bottom, depending on 'diffopt' and the
189                         width of the window relative to 'textwidth'.  Use
190                         Vim's |do| and |dp| to stage and unstage changes.
192                                                 *:Gdiffsplit!*
193 :Gdiffsplit!            Diff against any and all direct ancestors, retaining
194                         focus on the current window.  During a merge conflict,
195                         this is a three-way diff against the "ours" and
196                         "theirs" ancestors.  Additional d2o and d3o maps are
197                         provided to to obtain the hunk from the "ours" or
198                         "theirs" ancestor, respectively.
200 :Gdiffsplit! {object}   Like |:Gdiffsplit|, but retain focus on the current
201                         window.
203                                                 *:Gvdiffsplit*
204 :Gvdiffsplit [object]   Like |:Gdiffsplit|, but always split vertically.
206                                 *:Ghdiffsplit* *:Gsdiff*
207 :Ghdiffsplit [object]   Like |:Gdiffsplit|, but always split horizontally.
209                                                 *:Gmove*
210 :Gmove {destination}    Wrapper around git-mv that renames the buffer
211                         afterward.  Add a ! to pass -f.
213                                                 *:Grename*
214 :Grename {destination}  Like |:Gmove| but operates relative to the parent
215                         directory of the current file.
217                                                 *:Gdelete*
218 :Gdelete                Wrapper around git-rm that deletes the buffer
219                         afterward.  When invoked in an index file, --cached is
220                         passed.  Add a ! to pass -f and forcefully discard the
221                         buffer.
223                                                 *:Gremove*
224 :Gremove                Like :Gdelete, but keep the (now empty) buffer around.
226                                                 *:Gbrowse*
227 :Gbrowse                Open the current file, blob, tree, commit, or tag
228                         in your browser at the upstream hosting provider.
229                         If a range is given, it is appropriately appended to
230                         the URL as an anchor.
232                         Upstream providers can be added by installing an
233                         appropriate Vim plugin.  For example, GitHub can be
234                         supported by installing rhubarb.vim, available at
235                         <https://github.com/tpope/vim-rhubarb>.
237 :Gbrowse {object}       Like :Gbrowse, but for a given |fugitive-object|.
239 :Gbrowse [...]@{remote} Force using the given remote rather than the remote
240                         for the current branch.  The remote is used to
241                         determine which upstream repository to link to.
243 :{range}Gbrowse [args]  Appends an anchor to the URL that emphasizes the
244                         selected lines. This also forces the URL to include a
245                         commit rather than a branch name so it remains valid
246                         if the file changes.  You can give a range of "0" to
247                         force this behavior without including an anchor.
249 :[range]Gbrowse! [args] Like :Gbrowse, but put the URL on the clipboard rather
250                         than opening it.
252 MAPS                                            *fugitive-maps*
254 These maps are available in both the |:Gstatus| buffer and Fugitive object
255 buffers, although not all maps make sense in all buffers.  Mappings that
256 operate on the file or hunk under the cursor are generally available in visual
257 mode to operate on multiple files or partial hunks.
259                                                 *fugitive-staging-maps*
260 Staging/unstaging maps ~
262                                                 *fugitive_s*
263 s                       Stage (add) the file or hunk under the cursor.
265                                                 *fugitive_u*
266 u                       Unstage (reset) the file or hunk under the cursor.
268                                                 *fugitive_-*
269 -                       Stage or unstage the file or hunk under the cursor.
271                                                 *fugitive_U*
272 U                       Unstage everything.
274                                                 *fugitive_X*
275 X                       Discard the change under the cursor.  This uses
276                         `checkout` or `clean` under the hood.  A command is
277                         echoed that shows how to undo the change.  Consult
278                         `:messages` to see it again.  You can use this during
279                         a merge conflict do discard "our" changes (--theirs)
280                         in the "Unstaged" section or discard "their" changes
281                         (--ours) in the "Staged" section.
283                                                 *fugitive_=*
284 =                       Toggle an inline diff of the file under the cursor.
286                                                 *fugitive_>*
287 >                       Insert an inline diff of the file under the cursor.
289                                                 *fugitive_<*
290 <                       Remove the inline diff of the file under the cursor.
292                                                 *fugitive_gI*
293 gI                      Open .git/info/exclude in a split and add the file
294                         under the cursor.  Use a count to open .gitignore.
296                                                 *fugitive_I*
297 I                       Invoke |:Git| add --patch or reset --patch on the file
298 P                       under the cursor. On untracked files, this instead
299                         calls |:Git| add --intent-to-add.
301                                                 *fugitive_d*
302 Diff maps ~
303                                                 *fugitive_dp*
304 dp                      Invoke |:Git!| diff on the file under the cursor.
305                         Deprecated in favor of inline diffs.
307                                                 *fugitive_dd*
308 dd                      Perform a |:Gdiffsplit| on the file under the cursor.
310                                                 *fugitive_dv*
311 dv                      Perform a |:Gvdiffsplit| on the file under the cursor.
313                                                 *fugitive_ds* *fugitive_dh*
314 ds                      Perform a |:Ghdiffsplit| on the file under the cursor.
316                                                 *fugitive_dq*
317 dq                      Close all but one diff buffer, and |:diffoff|! the
318                         last one.
320                                                 *fugitive_d?*
321 d?                      Show this help.
323                                                 *fugitive-navigation-maps*
324 Navigation maps ~
326                                                 *fugitive_<CR>*
327 <CR>                    Open the file or |fugitive-object| under the cursor.
328                         in a blob, this and similar maps jump to the patch
329                         from the diff where this was added, or where it was
330                         removed if a count was given.  If the line is still in
331                         the work tree version, passing a count takes you to
332                         it.
334                                                 *fugitive_o*
335 o                       Open the file or |fugitive-object| under the cursor in
336                         a new split.
338                                                 *fugitive_gO*
339 gO                      Open the file or |fugitive-object| under the cursor in
340                         a new vertical split.
342                                                 *fugitive_O*
343 O                       Open the file or |fugitive-object| under the cursor in
344                         a new tab.
346                                                 *fugitive_p*
347 p                       Open the file or |fugitive-object| under the cursor in
348                         a preview window.  In the status buffer, 1p is
349                         required to bypass the legacy usage instructions.
351                                                 *fugitive_~*
352 ~                       Open the current file in the [count]th first ancestor.
354                                                 *fugitive_P*
355 P                       Open the current file in the [count]th parent.
357                                                 *fugitive_C*
358 C                       Open the commit containing the current file.
360                                                 *fugitive_CTRL-P* *fugitive_(*
361 (                       Jump to the previous file, hunk, or revision.
363                                                 *fugitive_CTRL-N* *fugitive_)*
364 )                       Jump to the next file, hunk, or revision.
366                                                 *fugitive_[c*
367 [c                      Jump to previous hunk, expanding inline diffs
368                         automatically.  (This shadows the Vim built-in |[c|
369                         that provides a similar operation in |diff| mode.)
371                                                 *fugitive_]c*
372 ]c                      Jump to next hunk, expanding inline diffs
373                         automatically.  (This shadows the Vim built-in |]c|
374                         that provides a similar operation in |diff| mode.)
376                                                 *fugitive_[/* *fugitive_[m*
377 [/                      Jump to previous file, collapsing inline diffs
378 [m                      automatically.  (Mnemonic: "/" appears in filenames,
379                         "m" appears in "filenames".)
381                                                 *fugitive_]/* *fugitive_]m*
382 ]/                      Jump to next file, collapsing inline diffs
383 ]m                      automatically.  (Mnemonic: "/" appears in filenames,
384                         "m" appears in "filenames".)
386                                                 *fugitive_i*
387 i                       Jump to the next file or hunk, expanding inline diffs
388                         automatically.
390                                                 *fugitive_[[*
391 [[                      Jump [count] sections backward.
393                                                 *fugitive_]]*
394 ]]                      Jump [count] sections forward.
396                                                 *fugitive_[]*
397 []                      Jump [count] section ends backward.
399                                                 *fugitive_][*
400 ][                      Jump [count] section ends forward.
402                                                 *fugitive_star*
403 *                       One the first column of a + or - diff line, search for
404                         the corresponding - or + line.  Otherwise, defer to
405                         built-in |star|.
407                                                 *fugitive_#*
408 #                       Same as "*", but search backward.
410                                                 *fugitive_gu*
411 gu                      Jump to file [count] in the "Untracked" or "Unstaged"
412                         section.
414                                                 *fugitive_gU*
415 gU                      Jump to file [count] in the "Unstaged" section.
417                                                 *fugitive_gs*
418 gs                      Jump to file [count] in the "Staged" section.
420                                                 *fugitive_gp*
421 gp                      Jump to file [count] in the "Unpushed" section.
423                                                 *fugitive_gP*
424 gP                      Jump to file [count] in the "Unpulled" section.
426                                                 *fugitive_gr*
427 gr                      Jump to file [count] in the "Rebasing" section.
429                                                 *fugitive_gi*
430 gi                      Open .git/info/exclude in a split.  Use a count to
431                         open .gitignore.
433                                                 *fugitive_c*
434 Commit maps ~
436 cc                      Create a commit.
438 ca                      Amend the last commit and edit the message.
440 ce                      Amend the last commit without editing the message.
442 cw                      Reword the last commit.
444 cvc                     Create a commit with -v.
446 cva                     Amend the last commit with -v
448 cf                      Create a `fixup!` commit for the commit under the
449                         cursor.
451 cF                      Create a `fixup!` commit for the commit under the
452                         cursor and immediately rebase it.
454 cs                      Create a `squash!` commit for the commit under the
455                         cursor.
457 cS                      Create a `squash!` commit for the commit under the
458                         cursor and immediately rebase it.
460 cA                      Create a `squash!` commit for the commit under the
461                         cursor and edit the message.
463 c<Space>                Populate command line with ":Git commit ".
465                                                 *fugitive_cr*
466 crc                     Revert the commit under the cursor.
468 crn                     Revert the commit under the cursor in the index and
469                         work tree, but do not actually commit the changes.
471 cr<Space>               Populate command line with ":Git revert ".
473                                                 *fugitive_cm*
474 cm<Space>               Populate command line with ":Git merge ".
476 c?                      Show this help.
478                                                 *fugitive_cb*
479                                                 *fugitive_co*
480 Checkout/branch maps ~
482 coo                     Check out the commit under the cursor.
484 cb<Space>               Populate command line with ":Git branch ".
486 co<Space>               Populate command line with ":Git checkout ".
488 cb?                     Show this help.
491                                                 *fugitive_cz*
492 Stash maps ~
494 czz                     Push stash.  Pass a [count] of 1 to add
495                         `--include-untracked` or 2 to add `--all`.
497 czw                     Push stash of worktree.  Like `czz` with
498                         `--include-index`.
500 czA                     Apply topmost stash, or stash@{count}.
502 cza                     Apply topmost stash, or stash@{count}, preserving the
503                         index.
505 czP                     Pop topmost stash, or stash@{count}.
507 czp                     Pop topmost stash, or stash@{count}, preserving the
508                         index.
510 cz<Space>               Populate command line with ":Git stash ".
512 cz?                     Show this help.
514                                                 *fugitive_r*
515 Rebase maps ~
517 ri                      Perform an interactive rebase.  Uses ancestor of
518 u                       commit under cursor as upstream if available.
520 rf                      Perform an autosquash rebase without editing the todo
521                         list.  Uses ancestor of commit under cursor as
522                         upstream if available.
524 ru                      Perform an interactive rebase against @{upstream}.
526 rp                      Perform an interactive rebase against @{push}.
528 rr                      Continue the current rebase.
530 rs                      Skip the current commit and continue the current
531                         rebase.
533 ra                      Abort the current rebase.
535 re                      Edit the current rebase todo list.
537 rw                      Perform an interactive rebase with the commit under
538                         the cursor set to `reword`.
540 rm                      Perform an interactive rebase with the commit under
541                         the cursor set to `edit`.
543 rd                      Perform an interactive rebase with the commit under
544                         the cursor set to `drop`.
546 r<Space>                Populate command line with ":Git rebase ".
548 r?                      Show this help.
550                                                 *fugitive-misc-maps*
551 Miscellaneous maps ~
553                                                 *fugitive_gq* *fugitive_q*
554 gq                      Close the status buffer.
556                                                 *fugitive_.*
557 .                       Start a |:| command line with the file under the
558                         cursor prepopulated.
560                                                 *fugitive_g?*
561 g?                      Show help for |fugitive-maps|.
563                                                 *fugitive-global-maps*
564 Global maps ~
566                                                 *fugitive_c_CTRL-R_CTRL-G*
567 <C-R><C-G>              On the command line, recall the path to the current
568                         |fugitive-object| (that is, a representation of the
569                         object recognized by |:Gedit|).
571                                                 *fugitive_y_CTRL-G*
572 ["x]y<C-G>              Yank the path to the current |fugitive-object|.
574                                                 *g:fugitive_no_maps*
575 Global maps can be disabled with the g:fugitive_no_maps option.
577         let g:fugitive_no_maps = 1
579 SPECIFYING OBJECTS                      *fugitive-object* *fugitive-revision*
581 Fugitive objects are either work tree files or Git revisions as defined in the
582 "SPECIFYING REVISIONS" section in the git-rev-parse man page, with expansions
583 inspired by |cmdline-special| layered on top.  For commands that accept an
584 optional object, the default is the file in the index for work tree files and
585 the work tree file for everything else.  Example objects follow.
587 Object          Meaning ~
588 @               The commit referenced by @ aka HEAD
589 master          The commit referenced by master
590 master^         The parent of the commit referenced by master
591 master...other  The merge base of master and other
592 master:         The tree referenced by master
593 ./master        The file named master in the working directory
594 :(top)master    The file named master in the work tree
595 Makefile        The file named Makefile in the work tree
596 @^:Makefile     The file named Makefile in the parent of HEAD
597 :Makefile       The file named Makefile in the index (writable)
598 @~2:%           The current file in the grandparent of HEAD
599 :%              The current file in the index
600 :1:%            The current file's common ancestor during a conflict
601 :2:#            The alternate file in the target branch during a conflict
602 :3:#5           The file from buffer #5 in the merged branch during a conflict
603 !               The commit owning the current file
604 !:Makefile      The file named Makefile in the commit owning the current file
605 !3^2            The second parent of the commit owning buffer #3
606 .git/config     The repo config file
607 :               Same as |:Gstatus|
609 STATUSLINE                                      *fugitive-statusline*
611                                 *FugitiveStatusline()* *fugitive#statusline()*
612 Add %{FugitiveStatusline()} to your statusline to get an indicator including
613 the current branch and the currently edited file's commit.  If you don't have
614 a statusline, this one matches the default when 'ruler' is set:
616         set statusline=%<%f\ %h%m%r%{FugitiveStatusline()}%=%-14.(%l,%c%V%)\ %P
618                                 *FugitiveHead(...)* *fugitive#head(...)*
619 Use FugitiveHead() to return the name of the current branch. If the current
620 HEAD is detached, FugitiveHead() will return the empty string, unless the
621 optional argument is given, in which case the hash of the current commit will
622 be truncated to the given number of characters.
624 ABOUT                                           *fugitive-about*
626 Grab the latest version or report a bug on GitHub:
628 https://github.com/tpope/vim-fugitive
630  vim:tw=78:et:ft=help:norl: