Misc doc improvements
[tig] / manual.txt
1 The tig Manual
2 ==============
3 Jonas Fonseca <fonseca@diku.dk>
4
5 This is the manual for tig, the ncurses-based text-mode interface for git.
6 Tig allows you to browse changes in a git repository and can additionally act
7 as a pager for output of various git commands. When used as a pager, it will
8 display input from stdin and colorize it.
9
10 When browsing repositories, tig uses the underlying git commands to present
11 the user with various views, such as summarized commit log and showing the
12 commit with the log message, diffstat, and the diff.
13
14 Calling Conventions
15 -------------------
16
17 Pager Mode
18 ~~~~~~~~~~
19
20 If stdin is a pipe, any log or diff options will be ignored and the pager view
21 will be opened loading data from stdin. The pager mode can be used for
22 colorizing output from various git commands.
23
24 Example on how to colorize the output of git-show(1):
25
26 -----------------------------------------------------------------------------
27 $ git show | tig
28 -----------------------------------------------------------------------------
29
30 Git Command Options
31 ~~~~~~~~~~~~~~~~~~~
32
33 All git command options specified on the command line will be passed to the
34 given command and all will be shell quoted before they are passed to the
35 shell.
36
37 NOTE: If you specify options for the main view, you should not use the
38 `--pretty` option as this option will be set automatically to the format
39 expected by the main view.
40
41 Example on how to open the log view and show both author and committer
42 information:
43
44 -----------------------------------------------------------------------------
45 $ tig log --pretty=fuller
46 -----------------------------------------------------------------------------
47
48 See the <<refspec, "Specifying revisions">> section below for an introduction
49 to revision options supported by the git commands. For details on specific git
50 command options, refer to the man page of the command in question.
51
52 Environment Variables
53 ---------------------
54
55 Several options related to the interface with git can be configured via
56 environment options.
57
58 Repository References
59 ~~~~~~~~~~~~~~~~~~~~~
60
61 Commits that are referenced by tags and branch heads will be marked by the
62 reference name surrounded by '[' and ']':
63
64 -----------------------------------------------------------------------------
65 2006-03-26 19:42 Petr Baudis         | [cogito-0.17.1] Cogito 0.17.1
66 -----------------------------------------------------------------------------
67
68 If you want to filter out certain directories under `.git/refs/`, say `tmp`
69 you can do it by setting the following variable:
70
71 -----------------------------------------------------------------------------
72 $ TIG_LS_REMOTE="git ls-remote . | sed /\/tmp\//d" tig
73 -----------------------------------------------------------------------------
74
75 Or set the variable permanently in your environment.
76
77 TIG_LS_REMOTE::
78         Set command for retrieving all repository references. The command
79         should output data in the same format as git-ls-remote(1).
80
81 [[history-commands]]
82 History Commands
83 ~~~~~~~~~~~~~~~~
84
85 It is possible to alter which commands are used for the different views.  If
86 for example you prefer commits in the main view to be sorted by date and only
87 show 500 commits, use:
88
89 -----------------------------------------------------------------------------
90 $ TIG_MAIN_CMD="git log --date-order -n500 --pretty=raw %s" tig
91 -----------------------------------------------------------------------------
92
93 Or set the variable permanently in your environment.
94
95 Notice, how `%s` is used to specify the commit reference. There can be a
96 maximum of 5 `%s` ref specifications.
97
98 TIG_DIFF_CMD::
99         The command used for the diff view. By default, git show is used
100         as a backend.
101
102 TIG_LOG_CMD::
103         The command used for the log view. If you prefer to have both
104         author and committer shown in the log view be sure to pass
105         `--pretty=fuller` to git log.
106
107 TIG_MAIN_CMD::
108         The command used for the main view. Note, you must always specify
109         the option: `--pretty=raw` since the main view parser expects to
110         read that format.
111
112 The Viewer
113 ----------
114
115 The display consists of a status window on the last line of the screen and one
116 or more views. The default is to only show one view at the time but it is
117 possible to split both the main and log view to also show the commit diff.
118
119 If you are in the log view and press 'Enter' when the current line is a commit
120 line, such as:
121
122 -----------------------------------------------------------------------------
123 commit 4d55caff4cc89335192f3e566004b4ceef572521
124 -----------------------------------------------------------------------------
125
126 You will split the view so that the log view is displayed in the top window
127 and the diff view in the bottom window. You can switch between the two views
128 by pressing 'Tab'. To maximize the log view again, simply press 'l'.
129
130 Current Head and Commit ID
131 ~~~~~~~~~~~~~~~~~~~~~~~~~~
132
133 The viewer keeps track of both what head and commit ID you are currently
134 viewing. The commit ID will follow the cursor line and change everytime time
135 you highlight a different commit. Whenever you reopen the diff view it will be
136 reloaded, if the commit ID changed.
137
138 The head ID is used when opening the main and log view to indicate from what
139 revision to show history.
140
141 Views
142 ~~~~~
143
144 Various 'views' of a repository is presented. Each view is based on output
145 from an external command, most often 'git log', 'git diff', or 'git show'.
146
147 The main view::
148         Is the default view, and it shows a one line summary of each commit
149         in the chosen list of revisions. The summary includes commit date,
150         author, and the first line of the log message. Additionally, any
151         repository references, such as tags, will be shown.
152
153 The log view::
154         Presents a more rich view of the revision log showing the whole log
155         message and the diffstat.
156
157 The diff view::
158         Shows either the diff of the current working tree, that is, what
159         has changed since the last commit, or the commit diff complete
160         with log message, diffstat and diff.
161
162 The pager view::
163         Is used for displaying both input from stdin and output from git
164         commands entered in the internal prompt.
165
166 The help view::
167         Displays key binding quick reference.
168
169 Title Windows
170 ~~~~~~~~~~~~~
171
172 Each view has a title window which shows the name of the view, current commit
173 ID if available, and where the view is positioned:
174
175 -----------------------------------------------------------------------------
176 [main] c622eefaa485995320bc743431bae0d497b1d875 - commit 1 of 61 (1%)
177 -----------------------------------------------------------------------------
178
179 By default, the title of the current view is highlighted using bold font.  For
180 long loading views (taking over 3 seconds) the time since loading started will
181 be appended:
182
183 -----------------------------------------------------------------------------
184 [main] 77d9e40fbcea3238015aea403e06f61542df9a31 - commit 1 of 779 (0%) 5s
185 -----------------------------------------------------------------------------
186
187 Keys
188 ----
189 Below the default key bindings are shown.
190
191 View Switching
192 ~~~~~~~~~~~~~~
193 m::
194         Switch to main view.
195 d::
196         Switch to diff view.
197 l::
198         Switch to log view.
199 p::
200         Switch to pager view.
201 h, ?::
202         Show man page.
203
204 View Manipulation
205 ~~~~~~~~~~~~~~~~~
206 q::
207         Close view, if multiple views are open it will jump back to the
208         previous view in the view stack. If it is the last open view it
209         will quit. Use 'Q' to quit all views at once.
210 Enter::
211         This key is "context sensitive" depending on what view you are
212         currently in. When in log view on a commit line or in the main
213         view, split the view and show the commit diff. In the diff view
214         pressing Enter will simply scroll the view one line down.
215 Tab::
216         Switch to next view.
217 Up::
218         This key is "context sensitive" and will move the cursor one
219         line up. However, uf you opened a diff view from the main view
220         (split- or full-screen) it will change the cursor to point to
221         the previous commit in the main view and update the diff view
222         to display it.
223 Down::
224         Similar to 'Up' but will move down.
225
226 Cursor Navigation
227 ~~~~~~~~~~~~~~~~~
228 j::
229         Move cursor one line up.
230 k::
231         Move cursor one line down.
232 PgUp::
233 b::
234 -::
235         Move cursor one page up.
236 PgDown::
237 Space::
238         Move cursor one page down.
239 Home::
240         Jump to first line.
241 End::
242         Jump to last line.
243
244 Scrolling
245 ~~~~~~~~~
246 Insert::
247         Scroll view one line up.
248 Delete::
249         Scroll view one line down.
250 w::
251         Scroll view one page up.
252 s::
253         Scroll view one page down.
254
255 Misc
256 ~~~~
257 Q::
258         Quit.
259 r::
260         Redraw screen.
261 z::
262         Stop all background loading. This can be useful if you use
263         tig in a repository with a long history without limiting
264         the revision log.
265 v::
266         Show version.
267 n::
268         Toggle line numbers on/off.
269 g::
270         Toggle revision graph visualization on/off.
271 ':'::
272         Open prompt. This allows you to specify what git command
273         to run. Example:
274
275         :log -p
276
277 [[refspec]]
278 Revision Specification
279 ----------------------
280
281 This section describes various ways to specify what revisions to display or
282 otherwise limit the view to. Tig does not itself parse the described
283 revision options so refer to the relevant git man pages for futher
284 information. Relevant man pages besides git-log(1) are git-diff(1) and
285 git-rev-list(1).
286
287 You can tune the interaction with git by making use of the options explained
288 in this section. For example, by configuring the environment variables
289 described in the  <<history-commands, "History commands">> section.
290
291 Limit by Path Name
292 ~~~~~~~~~~~~~~~~~~
293
294 If you are interested only in those revisions that made changes to a specific
295 file (or even several files) list the files like this:
296
297 -----------------------------------------------------------------------------
298 $ tig log Makefile README
299 -----------------------------------------------------------------------------
300
301 To avoid ambiguity with repository references such as tag name, be sure to
302 separate file names from other git options using "\--". So if you have a file
303 named 'master' it will clash with the reference named 'master', and thus you
304 will have to use:
305
306 -----------------------------------------------------------------------------
307 $ tig log -- master
308 -----------------------------------------------------------------------------
309
310 NOTE: For the main view, avoiding ambiguity will in some cases require you to
311 specify two "\--" options. The first will make tig stop option processing
312 and the latter will be passed to git log.
313
314 Limit by Date or Number
315 ~~~~~~~~~~~~~~~~~~~~~~~
316
317 To speed up interaction with git, you can limit the amount of commits to show
318 both for the log and main view. Either limit by date using e.g.
319 `--since=1.month` or limit by the number of commits using `-n400`.
320
321 If you are only interested in changed that happened between two dates you can
322 use:
323
324 -----------------------------------------------------------------------------
325 $ tig -- --after="May 5th" --before="2006-05-16 15:44"
326 -----------------------------------------------------------------------------
327
328 NOTE: If you want to avoid having to quote dates containing spaces you can use
329 "." instead, e.g. `--after=May.5th`.
330
331 Limiting by Commit Ranges
332 ~~~~~~~~~~~~~~~~~~~~~~~~~
333
334 Alternatively, commits can be limited to a specific range, such as "all
335 commits between 'tag-1.0' and 'tag-2.0'". For example:
336
337 -----------------------------------------------------------------------------
338 $ tig log tag-1.0..tag-2.0
339 -----------------------------------------------------------------------------
340
341 This way of commit limiting makes it trivial to only browse the commits which
342 haven't been pushed to a remote branch. Assuming 'origin' is your upstream
343 remote branch, using:
344
345 -----------------------------------------------------------------------------
346 $ tig log origin..HEAD
347 -----------------------------------------------------------------------------
348
349 will list what will be pushed to the remote branch. Optionally, the ending
350 'HEAD' can be left out since it is implied.
351
352 Limiting by Reachability
353 ~~~~~~~~~~~~~~~~~~~~~~~~
354
355 Git interprets the range specifier "tag-1.0..tag-2.0" as "all commits
356 reachable from 'tag-2.0' but not from 'tag-1.0'".  Where reachability refers
357 to what commits are ancestors (or part of the history) of the branch or tagged
358 revision in question.
359
360 If you prefer to specify which commit to preview in this way use the
361 following:
362
363 -----------------------------------------------------------------------------
364 $ tig log tag-2.0 ^tag-1.0
365 -----------------------------------------------------------------------------
366
367 You can think of '^' as a negation operator. Using this alternate syntax, it
368 is possible to further prune commits by specifying multiple branch cut offs.
369
370 Combining Revisions Specification
371 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
372
373 Revisions options can to some degree be combined, which makes it possible to
374 say "show at most 20 commits from within the last month that changed files
375 under the Documentation/ directory."
376
377 -----------------------------------------------------------------------------
378 $ tig -- --since=1.month -n20 -- Documentation/
379 -----------------------------------------------------------------------------
380
381 Examining All Repository References
382 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
383
384 In some cases, it can be useful to query changes across all references in a
385 repository. An example is to ask "did any line of development in this
386 repository change a particular file within the last week". This can be
387 accomplished using:
388
389 -----------------------------------------------------------------------------
390 $ tig -- --all --since=1.week -- Makefile
391 -----------------------------------------------------------------------------
392
393 include::BUGS[]
394
395 Copyright
396 ---------
397
398 Copyright (c) 2006 Jonas Fonseca <fonseca@diku.dk>
399
400 This program is free software; you can redistribute it and/or modify
401 it under the terms of the GNU General Public License as published by
402 the Free Software Foundation; either version 2 of the License, or
403 (at your option) any later version.
404
405 References and Related Tools
406 ----------------------------
407
408 Manpages:
409
410  - gitlink:tig[1]
411  - gitlink:tigrc[5]
412
413 Online resources:
414
415 include::SITES[]
416
417 Git porcelains:
418
419  - link:http://www.kernel.org/pub/software/scm/git/docs/[git],
420  - link:http://www.kernel.org/pub/software/scm/cogito/docs/[Cogito]
421
422 Other git repository browsers:
423
424  - gitk(1)
425  - qgit(1)
426  - gitview(1)