Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 218 lines (166 sloc) 10.628 kB
d527faa @tpope Update tag line
authored
1 *fugitive.txt* A Git wrapper so awesome, it should be illegal
1eb949b @tpope Initial commit
authored
2
3 Author: Tim Pope <vimNOSPAM@tpope.info> *fugitive-author*
4 License: Same terms as Vim itself (see |license|)
5
6 This plugin is only available if 'compatible' is not set.
7
8 INTRODUCTION *fugitive*
9
10 Install in ~/.vim, or in ~\vimfiles if you're on Windows and feeling lucky.
11 Vim 7.2 is recommended as it ships with syntax highlighting for many Git file
12 types.
13
14 If you're in a hurry to get started, here are some things to try:
15
16 In any file in your repository, run |:Gedit| HEAD. Press <CR> to jump to the
17 current branch. Press <CR> again to jump to the top most commit. Keep using
18 <CR> to explore parent commits, trees, and blobs. Use C in a tree or blob to
19 get back to the commit.
20
21 Edit a file in the work tree and make some changes. Use |:Gdiff| to open up
22 the indexed version. Use |do| and |dp| on various hunks to bring the files in
79339bf @tpope :Gread is now equivalent to :Gread!
authored
23 sync, or use |:Gread| to pull in all changes. Write the indexed version to
1eb949b @tpope Initial commit
authored
24 stage the file.
25
972f9d2 @tpope Mention :Gstatus and :Gcommit in introduction
authored
26 Run |:Gstatus| to check your repository's status. Use "-" to stage and reset
27 files and "p" to add/reset --patch them. Invoke |:Gcommit| to commit your
28 changes.
29
1eb949b @tpope Initial commit
authored
30 Run |:Gblame| in a work tree file to see a blame in a vertical split. Press
31 <CR> on any line to reopen and reblame that file as it stood in that commit.
32 Press o or O on any line to inspect that commit in a split or a tab.
33
a02331e @tpope Tweak formatting of introduction
authored
34 Run |:Ggrep| to search the work tree or history. Run |:Gmove| to rename a
35 file. Run |:Gremove| to delete a file.
1eb949b @tpope Initial commit
authored
36
37 COMMANDS *fugitive-commands*
38
39 These commands are local to the buffers in which they work (generally, buffers
40 that are part of Git repositories).
41
42 *fugitive-:Git*
43 :Git [args] Run an arbitrary git command. Similar to :!git [args]
44 but chdir to the repository tree first.
45
46 *fugitive-:Gcd*
47 :Gcd [directory] |:cd| relative to the repository.
48
49 *fugitive-:Glcd*
50 :Glcd [directory] |:lcd| relative to the repository.
51
39be351 @tpope Add :Gstatus with "-" map to stage and unstage
authored
52 *fugitive-:Gstatus*
3a25d0a @tpope Consistently use - when talking about git commands
authored
53 :Gstatus Bring up the output of git-status in the preview
39be351 @tpope Add :Gstatus with "-" map to stage and unstage
authored
54 window. Press - to stage or unstage the file on the
dc63e2d @tpope Press p in :Gstatus to add/reset --patch
authored
55 cursor line. Press p to do so on a per hunk basis
56 (--patch). Press C to invoke |:Gcommit|.
ec49a84 @tpope Add :Gcommit
authored
57
58 *fugitive-:Gcommit*
59 :Gcommit [args] A wrapper around git-commit. If there is nothing
60 to commit, |:Gstatus| is called instead. Unless the
61 arguments given would skip the invocation of an editor
62 (e.g., -m), a split window will be used to obtain a
63 commit message. Write and close that window (:wq or
64 |:Gwrite|) to finish the commit. Unlike when running
65 the actual git-commit command, it is possible (but
66 unadvisable) to muck with the index with commands like
67 git-add and git-reset while a commit message is
68 pending.
39be351 @tpope Add :Gstatus with "-" map to stage and unstage
authored
69
1eb949b @tpope Initial commit
authored
70 *fugitive-:Ggrep*
71 :Ggrep [args] |:grep| with git-grep as 'grepprg'.
72
73 *fugitive-:Glog*
037ce62 @tpope Pass :Glog arguments to git-log
authored
74 :Glog [args] Load all previous revisions of the current file into
75 the quickfix list. Additional git-log arguments can
76 be given (for example, --reverse). If "--" appears as
77 an argument, no file specific filtering is done, and
78 commits are loaded into the quickfix list.
1eb949b @tpope Initial commit
authored
79
80 *fugitive-:Gedit* *fugitive-:Ge*
81 :Gedit [revision] |:edit| a |fugitive-revision|.
82
83 *fugitive-:Gsplit*
84 :Gsplit [revision] |:split| a |fugitive-revision|.
85
86 *fugitive-:Gvsplit*
87 :Gvsplit [revision] |:vsplit| a |fugitive-revision|.
88
89 *fugitive-:Gtabedit*
90 :Gtabedit [revision] |:tabedit| a |fugitive-revision|
91
92 *fugitive-:Gpedit*
93 :Gpedit [revision] |:pedit| a |fugitive-revision|
94
95 *fugitive-:Gread*
79339bf @tpope :Gread is now equivalent to :Gread!
authored
96 :Gread [revision] Empty the buffer and |:read| a |fugitive-revision|.
3a25d0a @tpope Consistently use - when talking about git commands
authored
97 When the argument is omitted, this is similar to
98 git-checkout on a work tree file or git-add on a stage
79339bf @tpope :Gread is now equivalent to :Gread!
authored
99 file, but without writing anything to disk.
100
ecb2157 @tpope Deprecate :Gread with no range or bang
authored
101 :{range}Gread [revision]
79339bf @tpope :Gread is now equivalent to :Gread!
authored
102 |:read| in a |fugitive-revision| after {range}.
1eb949b @tpope Initial commit
authored
103
104 *fugitive-:Gread!*
79339bf @tpope :Gread is now equivalent to :Gread!
authored
105 :Gread! [revision] Deprecated synonym for |:Gread|.
1eb949b @tpope Initial commit
authored
106
04b845a @tpope Write to index and work tree with :Gwrite
authored
107 *fugitive-:Gwrite*
108 :Gwrite Write to the current file's path and stage the results.
109 When run in a work tree file, it is effectively git
3a25d0a @tpope Consistently use - when talking about git commands
authored
110 add. Elsewhere, it is effectively git-checkout. A
04b845a @tpope Write to index and work tree with :Gwrite
authored
111 great deal of effort is expended to behave sensibly
112 when the work tree or index version of the file is
113 open in another buffer.
114
115 :Gwrite {path} You can give |:Gwrite| an explicit path of where in
116 the work tree to write. You can also give a path like
117 :0:foo.txt or even :0 to write to just that stage in
118 the index.
119
1eb949b @tpope Initial commit
authored
120 *fugitive-:Gdiff*
b65030c @tpope :Gdiff does a three-way during a conflict
authored
121 :Gdiff [revision] Perform a |vimdiff| against the current file in the
122 given revision. With no argument, the version in the
123 index is used (which means a three-way diff during a
3a25d0a @tpope Consistently use - when talking about git commands
authored
124 merge conflict, making it a git-mergetool
eb48c6c @tpope In :Gdiff, newest file is shown on right
authored
125 alternative). The newer of the two files is placed
126 to the right. Use |do| and |dp| and write to the
3a25d0a @tpope Consistently use - when talking about git commands
authored
127 index file to simulate "git add --patch".
1eb949b @tpope Initial commit
authored
128
129 *fugitive-:Gmove*
130 :Gmove {destination} Wrapper around git-mv that renames the buffer
131 afterward. The destination is relative to the current
132 directory except when started with a /, in which case
133 it is relative to the work tree. Add a ! to pass -f.
134
135 *fugitive-:Gremove*
136 :Gremove Wrapper around git-rm that deletes the buffer
137 afterward. When invoked in an index file, --cached is
138 passed. Add a ! to pass -f and forcefully discard the
139 buffer.
140
141 *fugitive-:Gblame*
142 :Gblame Run git-blame on the file and open the results in a
143 scroll bound vertical split. Press enter on a line to
144 reblame the file as it was in that commit.
145
146 :[range]Gblame Run git-blame on the given range.
147
148 MAPPINGS *fugitive-mappings*
149
150 These maps are available in Git objects.
151
152 *fugitive-<CR>*
153 <CR> Jump to the revision under the cursor.
154
155 *fugitive-o*
156 o Jump to the revision under the cursor in a new split.
157
158 *fugitive-O*
159 O Jump to the revision under the cursor in a new tab.
160
161 *fugitive-~*
162 ~ Go to the current file in the [count]th first
163 ancestor.
164
165 *fugitive-P*
166 P Go to the current file in the [count]th parent.
167
168 *fugitive-C*
169 C Go to the commit containing the current file.
170
171 *fugitive-a*
172 a Show the current tag, commit, or tree in an alternate
173 format.
174
175 SPECIFYING REVISIONS *fugitive-revision*
176
177 Fugitive revisions are similar to Git revisions as defined in the "SPECIFYING
178 REVISIONS" section in the git-rev-parse man page. For commands that accept an
179 optional revision, the default is the file in the index for work tree files
180 and the work tree file for everything else. Example revisions follow.
181
182 Revision Meaning ~
183 HEAD .git/HEAD
184 master .git/refs/heads/master
185 HEAD^{} The commit referenced by HEAD
186 HEAD^ The parent of the commit referenced by HEAD
187 HEAD: The tree referenced by HEAD
188 /HEAD The file named HEAD in the work tree
189 Makefile The file named Makefile in the work tree
190 HEAD^:Makefile The file named Makefile in the parent of HEAD
191 :Makefile The file named Makefile in the index (writable)
192 - The current file in HEAD
193 ^ The current file in the previous commit
194 ~3 The current file 3 commits ago
39be351 @tpope Add :Gstatus with "-" map to stage and unstage
authored
195 : .git/index (Same as |:Gstatus|)
1eb949b @tpope Initial commit
authored
196 :0 The current file in the index
197 :1 The current file's common ancestor during a conflict
198 :2 The current file in the target branch during a conflict
199 :3 The current file in the merged branch during a conflict
200 :/foo The most recent commit with "foo" in the message
201
a27c0fc @tpope Add optional statusline indicator
authored
202 STATUSLINE *fugitive-statusline*
203
204 *fugitive#statusline()*
205 Add %{fugitive#statusline()} to your statusline to get an indicator including
206 the current branch and the currently edited file's commit. If you don't have
207 a statusline, this one matches the default when 'ruler' is set:
208 >
209 set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
210 <
1eb949b @tpope Initial commit
authored
211 ABOUT *fugitive-about*
212
ce56d61 @tpope Fix GitHub capitalization
authored
213 Grab the latest version or report a bug on GitHub:
1eb949b @tpope Initial commit
authored
214
215 http://github.com/tpope/vim-fugitive
216
217 vim:tw=78:et:ft=help:norl:
Something went wrong with that request. Please try again.