]> git.r.bdr.sh - rbdr/dotfiles/blame_incremental - vim/doc/fugitive.txt
Add gitignore
[rbdr/dotfiles] / vim / doc / fugitive.txt
... / ...
CommitLineData
1*fugitive.txt* A Git wrapper so awesome, it should be illegal
2
3Author: Tim Pope <http://tpo.pe/>
4License: Same terms as Vim itself (see |license|)
5
6This plugin is only available if 'compatible' is not set.
7
8INTRODUCTION *fugitive*
9
10Whenever you edit a file from a Git repository, a set of commands is defined
11that serve as a gateway to Git.
12
13COMMANDS *fugitive-commands*
14
15These commands are local to the buffers in which they work (generally, buffers
16that are part of Git repositories).
17
18 *fugitive-:Git*
19:Git [args] Run an arbitrary git command. Similar to :!git [args]
20 but chdir to the repository tree first.
21
22 *fugitive-:Git!*
23:Git! [args] Like |:Git|, but capture the output into a temp file,
24 and edit that temp file.
25
26 *fugitive-:Gcd*
27:Gcd [directory] |:cd| relative to the repository.
28
29 *fugitive-:Glcd*
30:Glcd [directory] |:lcd| relative to the repository.
31
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:
36
37 <C-N> next file
38 <C-P> previous file
39 <CR> |:Gedit|
40 - |:Git| add
41 - |:Git| reset (staged files)
42 C |:Gcommit|
43 cA |Gcommit| --amend --reuse-message=HEAD
44 ca |Gcommit| --amend
45 D |:Gdiff|
46 ds |:Gsdiff|
47 dp |:Git!| diff (p for patch; use :Gw to apply)
48 dp |:Git| add --intent-to-add (untracked files)
49 dv |:Gvdiff|
50 O |:Gtabedit|
51 o |:Gsplit|
52 p |:Git| add --patch
53 p |:Git| reset --patch (staged files)
54 q close status
55 R reload status
56
57 *fugitive-:Gcommit*
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
67 pending.
68
69 *fugitive-:Ggrep*
70:Ggrep [args] |:grep| with git-grep as 'grepprg'.
71
72 *fugitive-:Glog*
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.
78
79 *fugitive-:Gedit* *fugitive-:Ge*
80:Gedit [revision] |:edit| a |fugitive-revision|.
81
82 *fugitive-:Gsplit*
83:Gsplit [revision] |:split| a |fugitive-revision|.
84
85 *fugitive-:Gvsplit*
86:Gvsplit [revision] |:vsplit| a |fugitive-revision|.
87
88 *fugitive-:Gtabedit*
89:Gtabedit [revision] |:tabedit| a |fugitive-revision|.
90
91 *fugitive-:Gpedit*
92:Gpedit [revision] |:pedit| a |fugitive-revision|.
93
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.
98
99 *fugitive-:Gread*
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.
104
105:{range}Gread [revision]
106 |:read| in a |fugitive-revision| after {range}.
107
108 *fugitive-:Gread!*
109:Gread! [args] Empty the buffer and |:read| the output of a Git
110 command. For example, :Gread! show HEAD:%.
111
112:{range}Gread! [args] |:read| the output of a Git command after {range}.
113
114 *fugitive-:Gwrite*
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.
121
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
125 the index.
126
127 *fugitive-:Gwq*
128:Gwq [path] Like |:Gwrite| followed by |:quit| if the write
129 succeeded.
130
131:Gwq! [path] Like |:Gwrite|! followed by |:quit|! if the write
132 succeeded.
133
134 *fugitive-:Gdiff*
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".
142
143 *fugitive-:Gsdiff*
144:Gsdiff [revision] Like |:Gdiff|, but split horizontally.
145
146 *fugitive-:Gvdiff*
147:Gvdiff [revision] Identical to |:Gdiff|. For symmetry with |:Gsdiff|.
148
149 *fugitive-:Gmove*
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.
154
155 *fugitive-:Gremove*
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
159 buffer.
160
161 *fugitive-:Gblame*
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
166 along to git-blame.
167
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.
175
176:[range]Gblame [flags] Run git-blame on the given range.
177
178 *fugitive-:Gbrowse*
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.
186
187:[range]Gbrowse! Like :Gbrowse, but put the URL on the clipboard rather
188 than opening it.
189
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.
194
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.
199
200MAPPINGS *fugitive-mappings*
201
202These maps are available in Git objects.
203
204 *fugitive-<CR>*
205<CR> Jump to the revision under the cursor.
206
207 *fugitive-o*
208o Jump to the revision under the cursor in a new split.
209
210 *fugitive-O*
211O Jump to the revision under the cursor in a new tab.
212
213 *fugitive-~*
214~ Go to the current file in the [count]th first
215 ancestor.
216
217 *fugitive-P*
218P Go to the current file in the [count]th parent.
219
220 *fugitive-C*
221C Go to the commit containing the current file.
222
223 *fugitive-a*
224a Show the current tag, commit, or tree in an alternate
225 format.
226
227SPECIFYING REVISIONS *fugitive-revision*
228
229Fugitive revisions are similar to Git revisions as defined in the "SPECIFYING
230REVISIONS" section in the git-rev-parse man page. For commands that accept an
231optional revision, the default is the file in the index for work tree files
232and the work tree file for everything else. Example revisions follow.
233
234Revision Meaning ~
235HEAD .git/HEAD
236master .git/refs/heads/master
237HEAD^{} The commit referenced by HEAD
238HEAD^ The parent of the commit referenced by HEAD
239HEAD: The tree referenced by HEAD
240/HEAD The file named HEAD in the work tree
241Makefile The file named Makefile in the work tree
242HEAD^: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
253
254STATUSLINE *fugitive-statusline*
255
256 *fugitive#statusline()*
257Add %{fugitive#statusline()} to your statusline to get an indicator including
258the current branch and the currently edited file's commit. If you don't have
259a statusline, this one matches the default when 'ruler' is set:
260>
261 set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
262<
263ABOUT *fugitive-about*
264
265Grab the latest version or report a bug on GitHub:
266
267http://github.com/tpope/vim-fugitive
268
269 vim:tw=78:et:ft=help:norl: