fugitive.txt (11152B)
1 *fugitive.txt* A Git wrapper so awesome, it should be illegal 2 3 Author: Tim Pope <vimNOSPAM@tpope.org> *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 23 sync, or use |:Gread| to pull in all changes. Write the indexed version to 24 stage the file. 25 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 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 34 Run |:Ggrep| to search the work tree or history. Run |:Gmove| to rename a 35 file. Run |:Gremove| to delete a file. 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 52 *fugitive-:Gstatus* 53 :Gstatus Bring up the output of git-status in the preview 54 window. In addition to standard motions, you can 55 use <C-N> and <C-P> to jump from filename to 56 filename. Press D to |:Gdiff| the file on the cursor 57 line, or dh to |:Gdiff!|. Press - to stage or unstage 58 the file on the cursor line. Press p to do so on a 59 per hunk basis (--patch). Press C to invoke 60 |:Gcommit|. 61 62 *fugitive-:Gcommit* 63 :Gcommit [args] A wrapper around git-commit. If there is nothing 64 to commit, |:Gstatus| is called instead. Unless the 65 arguments given would skip the invocation of an editor 66 (e.g., -m), a split window will be used to obtain a 67 commit message. Write and close that window (:wq or 68 |:Gwrite|) to finish the commit. Unlike when running 69 the actual git-commit command, it is possible (but 70 unadvisable) to muck with the index with commands like 71 git-add and git-reset while a commit message is 72 pending. 73 74 *fugitive-:Ggrep* 75 :Ggrep [args] |:grep| with git-grep as 'grepprg'. 76 77 *fugitive-:Glog* 78 :Glog [args] Load all previous revisions of the current file into 79 the quickfix list. Additional git-log arguments can 80 be given (for example, --reverse). If "--" appears as 81 an argument, no file specific filtering is done, and 82 commits are loaded into the quickfix list. 83 84 *fugitive-:Gedit* *fugitive-:Ge* 85 :Gedit [revision] |:edit| a |fugitive-revision|. 86 87 *fugitive-:Gsplit* 88 :Gsplit [revision] |:split| a |fugitive-revision|. 89 90 *fugitive-:Gvsplit* 91 :Gvsplit [revision] |:vsplit| a |fugitive-revision|. 92 93 *fugitive-:Gtabedit* 94 :Gtabedit [revision] |:tabedit| a |fugitive-revision| 95 96 *fugitive-:Gpedit* 97 :Gpedit [revision] |:pedit| a |fugitive-revision| 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! [revision] Deprecated synonym for |:Gread|. 110 111 *fugitive-:Gwrite* 112 :Gwrite Write to the current file's path and stage the results. 113 When run in a work tree file, it is effectively git 114 add. Elsewhere, it is effectively git-checkout. A 115 great deal of effort is expended to behave sensibly 116 when the work tree or index version of the file is 117 open in another buffer. 118 119 :Gwrite {path} You can give |:Gwrite| an explicit path of where in 120 the work tree to write. You can also give a path like 121 :0:foo.txt or even :0 to write to just that stage in 122 the index. 123 124 *fugitive-:Gdiff* 125 :Gdiff [revision] Perform a |vimdiff| against the current file in the 126 given revision. With no argument, the version in the 127 index is used (which means a three-way diff during a 128 merge conflict, making it a git-mergetool 129 alternative). The newer of the two files is placed 130 to the right. Use |do| and |dp| and write to the 131 index file to simulate "git add --patch". 132 133 *fugitive-:Gdiff!* 134 :Gdiff! [revision] Like |:Gdiff|, but split horizontally. 135 136 *fugitive-:Gmove* 137 :Gmove {destination} Wrapper around git-mv that renames the buffer 138 afterward. The destination is relative to the current 139 directory except when started with a /, in which case 140 it is relative to the work tree. Add a ! to pass -f. 141 142 *fugitive-:Gremove* 143 :Gremove Wrapper around git-rm that deletes the buffer 144 afterward. When invoked in an index file, --cached is 145 passed. Add a ! to pass -f and forcefully discard the 146 buffer. 147 148 *fugitive-:Gblame* 149 :Gblame [flags] Run git-blame on the file and open the results in a 150 scroll bound vertical split. Press enter on a line to 151 reblame the file as it was in that commit. You can 152 give any of ltwfsMC as flags and they will be passed 153 along to git-blame. 154 155 :[range]Gblame [flags] Run git-blame on the given range. 156 157 MAPPINGS *fugitive-mappings* 158 159 These maps are available in Git objects. 160 161 *fugitive-<CR>* 162 <CR> Jump to the revision under the cursor. 163 164 *fugitive-o* 165 o Jump to the revision under the cursor in a new split. 166 167 *fugitive-O* 168 O Jump to the revision under the cursor in a new tab. 169 170 *fugitive-~* 171 ~ Go to the current file in the [count]th first 172 ancestor. 173 174 *fugitive-P* 175 P Go to the current file in the [count]th parent. 176 177 *fugitive-C* 178 C Go to the commit containing the current file. 179 180 *fugitive-a* 181 a Show the current tag, commit, or tree in an alternate 182 format. 183 184 SPECIFYING REVISIONS *fugitive-revision* 185 186 Fugitive revisions are similar to Git revisions as defined in the "SPECIFYING 187 REVISIONS" section in the git-rev-parse man page. For commands that accept an 188 optional revision, the default is the file in the index for work tree files 189 and the work tree file for everything else. Example revisions follow. 190 191 Revision Meaning ~ 192 HEAD .git/HEAD 193 master .git/refs/heads/master 194 HEAD^{} The commit referenced by HEAD 195 HEAD^ The parent of the commit referenced by HEAD 196 HEAD: The tree referenced by HEAD 197 /HEAD The file named HEAD in the work tree 198 Makefile The file named Makefile in the work tree 199 HEAD^:Makefile The file named Makefile in the parent of HEAD 200 :Makefile The file named Makefile in the index (writable) 201 - The current file in HEAD 202 ^ The current file in the previous commit 203 ~3 The current file 3 commits ago 204 : .git/index (Same as |:Gstatus|) 205 :0 The current file in the index 206 :1 The current file's common ancestor during a conflict 207 :2 The current file in the target branch during a conflict 208 :3 The current file in the merged branch during a conflict 209 :/foo The most recent commit with "foo" in the message 210 211 STATUSLINE *fugitive-statusline* 212 213 *fugitive#statusline()* 214 Add %{fugitive#statusline()} to your statusline to get an indicator including 215 the current branch and the currently edited file's commit. If you don't have 216 a statusline, this one matches the default when 'ruler' is set: 217 > 218 set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P 219 < 220 ABOUT *fugitive-about* 221 222 Grab the latest version or report a bug on GitHub: 223 224 http://github.com/tpope/vim-fugitive 225 226 vim:tw=78:et:ft=help:norl: