Merge branch 'mt/checkout-entry-dead-code-removal'
[git] / Documentation / git-log.txt
1 git-log(1)
2 ==========
3
4 NAME
5 ----
6 git-log - Show commit logs
7
8
9 SYNOPSIS
10 --------
11 [verse]
12 'git log' [<options>] [<revision range>] [[--] <path>...]
13
14 DESCRIPTION
15 -----------
16 Shows the commit logs.
17
18 :git-log: 1
19 include::rev-list-description.txt[]
20
21 The command takes options applicable to the linkgit:git-rev-list[1]
22 command to control what is shown and how, and options applicable to
23 the linkgit:git-diff[1] command to control how the changes
24 each commit introduces are shown.
25
26
27 OPTIONS
28 -------
29
30 --follow::
31         Continue listing the history of a file beyond renames
32         (works only for a single file).
33
34 --no-decorate::
35 --decorate[=short|full|auto|no]::
36         Print out the ref names of any commits that are shown. If 'short' is
37         specified, the ref name prefixes 'refs/heads/', 'refs/tags/' and
38         'refs/remotes/' will not be printed. If 'full' is specified, the
39         full ref name (including prefix) will be printed. If 'auto' is
40         specified, then if the output is going to a terminal, the ref names
41         are shown as if 'short' were given, otherwise no ref names are
42         shown. The default option is 'short'.
43
44 --decorate-refs=<pattern>::
45 --decorate-refs-exclude=<pattern>::
46         If no `--decorate-refs` is given, pretend as if all refs were
47         included.  For each candidate, do not use it for decoration if it
48         matches any patterns given to `--decorate-refs-exclude` or if it
49         doesn't match any of the patterns given to `--decorate-refs`. The
50         `log.excludeDecoration` config option allows excluding refs from
51         the decorations, but an explicit `--decorate-refs` pattern will
52         override a match in `log.excludeDecoration`.
53
54 --source::
55         Print out the ref name given on the command line by which each
56         commit was reached.
57
58 --[no-]mailmap::
59 --[no-]use-mailmap::
60         Use mailmap file to map author and committer names and email
61         addresses to canonical real names and email addresses. See
62         linkgit:git-shortlog[1].
63
64 --full-diff::
65         Without this flag, `git log -p <path>...` shows commits that
66         touch the specified paths, and diffs about the same specified
67         paths.  With this, the full diff is shown for commits that touch
68         the specified paths; this means that "<path>..." limits only
69         commits, and doesn't limit diff for those commits.
70 +
71 Note that this affects all diff-based output types, e.g. those
72 produced by `--stat`, etc.
73
74 --log-size::
75         Include a line ``log size <number>'' in the output for each commit,
76         where <number> is the length of that commit's message in bytes.
77         Intended to speed up tools that read log messages from `git log`
78         output by allowing them to allocate space in advance.
79
80 -L <start>,<end>:<file>::
81 -L :<funcname>:<file>::
82         Trace the evolution of the line range given by "<start>,<end>"
83         (or the function name regex <funcname>) within the <file>.  You may
84         not give any pathspec limiters.  This is currently limited to
85         a walk starting from a single revision, i.e., you may only
86         give zero or one positive revision arguments, and
87         <start> and <end> (or <funcname>) must exist in the starting revision.
88         You can specify this option more than once. Implies `--patch`.
89         Patch output can be suppressed using `--no-patch`, but other diff formats
90         (namely `--raw`, `--numstat`, `--shortstat`, `--dirstat`, `--summary`,
91         `--name-only`, `--name-status`, `--check`) are not currently implemented.
92 +
93 include::line-range-format.txt[]
94
95 <revision range>::
96         Show only commits in the specified revision range.  When no
97         <revision range> is specified, it defaults to `HEAD` (i.e. the
98         whole history leading to the current commit).  `origin..HEAD`
99         specifies all the commits reachable from the current commit
100         (i.e. `HEAD`), but not from `origin`. For a complete list of
101         ways to spell <revision range>, see the 'Specifying Ranges'
102         section of linkgit:gitrevisions[7].
103
104 [--] <path>...::
105         Show only commits that are enough to explain how the files
106         that match the specified paths came to be.  See 'History
107         Simplification' below for details and other simplification
108         modes.
109 +
110 Paths may need to be prefixed with `--` to separate them from
111 options or the revision range, when confusion arises.
112
113 include::rev-list-options.txt[]
114
115 include::pretty-formats.txt[]
116
117 DIFF FORMATTING
118 ---------------
119
120 By default, `git log` does not generate any diff output. The options
121 below can be used to show the changes made by each commit.
122
123 Note that unless one of `-c`, `--cc`, or `-m` is given, merge commits
124 will never show a diff, even if a diff format like `--patch` is
125 selected, nor will they match search options like `-S`. The exception is
126 when `--first-parent` is in use, in which merges are treated like normal
127 single-parent commits (this can be overridden by providing a
128 combined-diff option or with `--no-diff-merges`).
129
130 -c::
131         With this option, diff output for a merge commit
132         shows the differences from each of the parents to the merge result
133         simultaneously instead of showing pairwise diff between a parent
134         and the result one at a time. Furthermore, it lists only files
135         which were modified from all parents.
136
137 --cc::
138         This flag implies the `-c` option and further compresses the
139         patch output by omitting uninteresting hunks whose contents in
140         the parents have only two variants and the merge result picks
141         one of them without modification.
142
143 --combined-all-paths::
144         This flag causes combined diffs (used for merge commits) to
145         list the name of the file from all parents.  It thus only has
146         effect when -c or --cc are specified, and is likely only
147         useful if filename changes are detected (i.e. when either
148         rename or copy detection have been requested).
149
150 -m::
151         This flag makes the merge commits show the full diff like
152         regular commits; for each merge parent, a separate log entry
153         and diff is generated. An exception is that only diff against
154         the first parent is shown when `--first-parent` option is given;
155         in that case, the output represents the changes the merge
156         brought _into_ the then-current branch.
157
158 --diff-merges=off::
159 --no-diff-merges::
160         Disable output of diffs for merge commits (default). Useful to
161         override `-m`, `-c`, or `--cc`.
162
163 :git-log: 1
164 include::diff-options.txt[]
165
166 include::diff-generate-patch.txt[]
167
168 EXAMPLES
169 --------
170 `git log --no-merges`::
171
172         Show the whole commit history, but skip any merges
173
174 `git log v2.6.12.. include/scsi drivers/scsi`::
175
176         Show all commits since version 'v2.6.12' that changed any file
177         in the `include/scsi` or `drivers/scsi` subdirectories
178
179 `git log --since="2 weeks ago" -- gitk`::
180
181         Show the changes during the last two weeks to the file 'gitk'.
182         The `--` is necessary to avoid confusion with the *branch* named
183         'gitk'
184
185 `git log --name-status release..test`::
186
187         Show the commits that are in the "test" branch but not yet
188         in the "release" branch, along with the list of paths
189         each commit modifies.
190
191 `git log --follow builtin/rev-list.c`::
192
193         Shows the commits that changed `builtin/rev-list.c`, including
194         those commits that occurred before the file was given its
195         present name.
196
197 `git log --branches --not --remotes=origin`::
198
199         Shows all commits that are in any of local branches but not in
200         any of remote-tracking branches for 'origin' (what you have that
201         origin doesn't).
202
203 `git log master --not --remotes=*/master`::
204
205         Shows all commits that are in local master but not in any remote
206         repository master branches.
207
208 `git log -p -m --first-parent`::
209
210         Shows the history including change diffs, but only from the
211         ``main branch'' perspective, skipping commits that come from merged
212         branches, and showing full diffs of changes introduced by the merges.
213         This makes sense only when following a strict policy of merging all
214         topic branches when staying on a single integration branch.
215
216 `git log -L '/int main/',/^}/:main.c`::
217
218         Shows how the function `main()` in the file `main.c` evolved
219         over time.
220
221 `git log -3`::
222
223         Limits the number of commits to show to 3.
224
225 DISCUSSION
226 ----------
227
228 include::i18n.txt[]
229
230 CONFIGURATION
231 -------------
232
233 See linkgit:git-config[1] for core variables and linkgit:git-diff[1]
234 for settings related to diff generation.
235
236 format.pretty::
237         Default for the `--format` option.  (See 'Pretty Formats' above.)
238         Defaults to `medium`.
239
240 i18n.logOutputEncoding::
241         Encoding to use when displaying logs.  (See 'Discussion' above.)
242         Defaults to the value of `i18n.commitEncoding` if set, and UTF-8
243         otherwise.
244
245 log.date::
246         Default format for human-readable dates.  (Compare the
247         `--date` option.)  Defaults to "default", which means to write
248         dates like `Sat May 8 19:35:34 2010 -0500`.
249 +
250 If the format is set to "auto:foo" and the pager is in use, format
251 "foo" will be the used for the date format. Otherwise "default" will
252 be used.
253
254 log.follow::
255         If `true`, `git log` will act as if the `--follow` option was used when
256         a single <path> is given.  This has the same limitations as `--follow`,
257         i.e. it cannot be used to follow multiple files and does not work well
258         on non-linear history.
259
260 log.showRoot::
261         If `false`, `git log` and related commands will not treat the
262         initial commit as a big creation event.  Any root commits in
263         `git log -p` output would be shown without a diff attached.
264         The default is `true`.
265
266 log.showSignature::
267         If `true`, `git log` and related commands will act as if the
268         `--show-signature` option was passed to them.
269
270 mailmap.*::
271         See linkgit:git-shortlog[1].
272
273 notes.displayRef::
274         Which refs, in addition to the default set by `core.notesRef`
275         or `GIT_NOTES_REF`, to read notes from when showing commit
276         messages with the `log` family of commands.  See
277         linkgit:git-notes[1].
278 +
279 May be an unabbreviated ref name or a glob and may be specified
280 multiple times.  A warning will be issued for refs that do not exist,
281 but a glob that does not match any refs is silently ignored.
282 +
283 This setting can be disabled by the `--no-notes` option,
284 overridden by the `GIT_NOTES_DISPLAY_REF` environment variable,
285 and overridden by the `--notes=<ref>` option.
286
287 GIT
288 ---
289 Part of the linkgit:git[1] suite