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