vim-fugitive
[my-vim-dotfolder.git] / bundle / vim-fugitive / doc / fugitive.txt
blob51addb4df9f2a8cf9934b277d75cbf61798be620
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                                                 *fugitive-:Git*
19 :Git [args]             Run an arbitrary git command. Similar to :!git [args]
20                         but chdir to the repository tree first.
22                                                 *fugitive-:Git!*
23 :Git! [args]            Like |:Git|, but capture the output into a temp file,
24                         and edit that temp file.
26                                                 *fugitive-:Gcd*
27 :Gcd [directory]        |:cd| relative to the repository.
29                                                 *fugitive-:Glcd*
30 :Glcd [directory]       |:lcd| relative to the repository.
32                                                 *fugitive-:Gstatus*
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:
37                         <C-N> next file
38                         <C-P> previous file
39                         <CR>  |:Gedit|
40                         -     |:Git| add
41                         -     |:Git| reset (staged files)
42                         cA    |:Gcommit| --amend --reuse-message=HEAD
43                         ca    |:Gcommit| --amend
44                         cc    |:Gcommit|
45                         cva   |:Gcommit| --amend --verbose
46                         cvc   |:Gcommit| --verbose
47                         D     |:Gdiff|
48                         ds    |:Gsdiff|
49                         dp    |:Git!| diff (p for patch; use :Gw to apply)
50                         dp    |:Git| add --intent-to-add (untracked files)
51                         dv    |:Gvdiff|
52                         O     |:Gtabedit|
53                         o     |:Gsplit|
54                         p     |:Git| add --patch
55                         p     |:Git| reset --patch (staged files)
56                         q     close status
57                         R     reload status
58                         S     |:Gvsplit|
60                                                 *fugitive-:Gcommit*
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
70                         pending.
72                                                 *fugitive-:Ggrep*
73 :Ggrep [args]           |:grep| with git-grep as 'grepprg'.
75                                                 *fugitive-:Glgrep*
76 :Glgrep [args]          |:lgrep| with git-grep as 'grepprg'.
78                                                 *fugitive-:Glog*
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
84                         are loaded.
86                                                 *fugitive-:Gllog*
87 :Gllog [args]           Like |:Glog|, but use the location list instead of the
88                         quickfix list.
90                                         *fugitive-:Gedit* *fugitive-:Ge*
91 :Gedit [revision]       |:edit| a |fugitive-revision|.
93                                                 *fugitive-:Gsplit*
94 :Gsplit [revision]      |:split| a |fugitive-revision|.
96                                                 *fugitive-:Gvsplit*
97 :Gvsplit [revision]     |:vsplit| a |fugitive-revision|.
99                                                 *fugitive-:Gtabedit*
100 :Gtabedit [revision]    |:tabedit| a |fugitive-revision|.
102                                                 *fugitive-:Gpedit*
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.
110                                                 *fugitive-:Gread*
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}.
119                                                 *fugitive-:Gread!*
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}.
125                                                 *fugitive-:Gwrite*
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
136                         the index.
138                                                 *fugitive-:Gwq*
139 :Gwq [path]             Like |:Gwrite| followed by |:quit| if the write
140                         succeeded.
142 :Gwq! [path]            Like |:Gwrite|! followed by |:quit|! if the write
143                         succeeded.
145                                                 *fugitive-:Gdiff*
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".
154                                                 *fugitive-:Gsdiff*
155 :Gsdiff [revision]      Like |:Gdiff|, but split horizontally.
157                                                 *fugitive-:Gvdiff*
158 :Gvdiff [revision]      Identical to |:Gdiff|.  For symmetry with |:Gsdiff|.
160                                                 *fugitive-:Gmove*
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.
166                                                 *fugitive-:Gremove*
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
170                         buffer.
172                                                 *fugitive-:Gblame*
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
188                         -     reblame at commit
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.
194                                                 *fugitive-:Gbrowse*
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
209                         than opening it.
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|).
230                                                 *fugitive-y_CTRL-G*
231 ["x]y<C-G>              Yank the commit SHA and path to the current object.
233 These maps are available in Git objects.
235                                                 *fugitive-<CR>*
236 <CR>                    Jump to the revision under the cursor.
238                                                 *fugitive-o*
239 o                       Jump to the revision under the cursor in a new split.
241                                                 *fugitive-S*
242 S                       Jump to the revision under the cursor in a new
243                         vertical split.
245                                                 *fugitive-O*
246 O                       Jump to the revision under the cursor in a new tab.
248                                                 *fugitive--*
249 -                       Go to the tree containing the current tree or blob.
251                                                 *fugitive-~*
252 ~                       Go to the current file in the [count]th first
253                         ancestor.
255                                                 *fugitive-P*
256 P                       Go to the current file in the [count]th parent.
258                                                 *fugitive-C*
259 C                       Go to the commit containing the current file.
261                                                 *fugitive-a*
262 a                       Show the current tag, commit, or tree in an alternate
263                         format.
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.
272 Revision        Meaning ~
273 HEAD            .git/HEAD
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
301                                                 *fugitive#head(...)*
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: