1GIT-ANNOTATE(1) Git Manual GIT-ANNOTATE(1)
2
3
4
6 git-annotate - Annotate file lines with commit information
7
9 git annotate [<options>] [<rev-opts>] [<rev>] [--] <file>
10
12 Annotates each line in the given file with information from the commit
13 which introduced the line. Optionally annotates from a given revision.
14
15 The only difference between this command and git-blame(1) is that they
16 use slightly different output formats, and this command exists only for
17 backward compatibility to support existing scripts, and provide a more
18 familiar command name for people coming from other SCM systems.
19
21 -b
22 Show blank SHA-1 for boundary commits. This can also be controlled
23 via the blame.blankBoundary config option.
24
25 --root
26 Do not treat root commits as boundaries. This can also be
27 controlled via the blame.showRoot config option.
28
29 --show-stats
30 Include additional statistics at the end of blame output.
31
32 -L <start>,<end>, -L :<funcname>
33 Annotate only the line range given by <start>,<end>, or by the
34 function name regex <funcname>. May be specified multiple times.
35 Overlapping ranges are allowed.
36
37 <start> and <end> are optional. -L <start> or -L <start>, spans
38 from <start> to end of file. -L ,<end> spans from start of file to
39 <end>.
40
41 <start> and <end> can take one of these forms:
42
43 • number
44
45 If <start> or <end> is a number, it specifies an absolute line
46 number (lines count from 1).
47
48 • /regex/
49
50 This form will use the first line matching the given POSIX
51 regex. If <start> is a regex, it will search from the end of
52 the previous -L range, if any, otherwise from the start of
53 file. If <start> is ^/regex/, it will search from the start of
54 file. If <end> is a regex, it will search starting at the line
55 given by <start>.
56
57 • +offset or -offset
58
59 This is only valid for <end> and will specify a number of lines
60 before or after the line given by <start>.
61
62 If :<funcname> is given in place of <start> and <end>, it is a
63 regular expression that denotes the range from the first funcname
64 line that matches <funcname>, up to the next funcname line.
65 :<funcname> searches from the end of the previous -L range, if any,
66 otherwise from the start of file. ^:<funcname> searches from the
67 start of file. The function names are determined in the same way as
68 git diff works out patch hunk headers (see Defining a custom
69 hunk-header in gitattributes(5)).
70
71 -l
72 Show long rev (Default: off).
73
74 -t
75 Show raw timestamp (Default: off).
76
77 -S <revs-file>
78 Use revisions from revs-file instead of calling git-rev-list(1).
79
80 --reverse <rev>..<rev>
81 Walk history forward instead of backward. Instead of showing the
82 revision in which a line appeared, this shows the last revision in
83 which a line has existed. This requires a range of revision like
84 START..END where the path to blame exists in START. git blame
85 --reverse START is taken as git blame --reverse START..HEAD for
86 convenience.
87
88 --first-parent
89 Follow only the first parent commit upon seeing a merge commit.
90 This option can be used to determine when a line was introduced to
91 a particular integration branch, rather than when it was introduced
92 to the history overall.
93
94 -p, --porcelain
95 Show in a format designed for machine consumption.
96
97 --line-porcelain
98 Show the porcelain format, but output commit information for each
99 line, not just the first time a commit is referenced. Implies
100 --porcelain.
101
102 --incremental
103 Show the result incrementally in a format designed for machine
104 consumption.
105
106 --encoding=<encoding>
107 Specifies the encoding used to output author names and commit
108 summaries. Setting it to none makes blame output unconverted data.
109 For more information see the discussion about encoding in the git-
110 log(1) manual page.
111
112 --contents <file>
113 Annotate using the contents from the named file, starting from
114 <rev> if it is specified, and HEAD otherwise. You may specify - to
115 make the command read from the standard input for the file
116 contents.
117
118 --date <format>
119 Specifies the format used to output dates. If --date is not
120 provided, the value of the blame.date config variable is used. If
121 the blame.date config variable is also not set, the iso format is
122 used. For supported values, see the discussion of the --date option
123 at git-log(1).
124
125 --[no-]progress
126 Progress status is reported on the standard error stream by default
127 when it is attached to a terminal. This flag enables progress
128 reporting even if not attached to a terminal. Can’t use --progress
129 together with --porcelain or --incremental.
130
131 -M[<num>]
132 Detect moved or copied lines within a file. When a commit moves or
133 copies a block of lines (e.g. the original file has A and then B,
134 and the commit changes it to B and then A), the traditional blame
135 algorithm notices only half of the movement and typically blames
136 the lines that were moved up (i.e. B) to the parent and assigns
137 blame to the lines that were moved down (i.e. A) to the child
138 commit. With this option, both groups of lines are blamed on the
139 parent by running extra passes of inspection.
140
141 <num> is optional but it is the lower bound on the number of
142 alphanumeric characters that Git must detect as moving/copying
143 within a file for it to associate those lines with the parent
144 commit. The default value is 20.
145
146 -C[<num>]
147 In addition to -M, detect lines moved or copied from other files
148 that were modified in the same commit. This is useful when you
149 reorganize your program and move code around across files. When
150 this option is given twice, the command additionally looks for
151 copies from other files in the commit that creates the file. When
152 this option is given three times, the command additionally looks
153 for copies from other files in any commit.
154
155 <num> is optional but it is the lower bound on the number of
156 alphanumeric characters that Git must detect as moving/copying
157 between files for it to associate those lines with the parent
158 commit. And the default value is 40. If there are more than one -C
159 options given, the <num> argument of the last -C will take effect.
160
161 --ignore-rev <rev>
162 Ignore changes made by the revision when assigning blame, as if the
163 change never happened. Lines that were changed or added by an
164 ignored commit will be blamed on the previous commit that changed
165 that line or nearby lines. This option may be specified multiple
166 times to ignore more than one revision. If the
167 blame.markIgnoredLines config option is set, then lines that were
168 changed by an ignored commit and attributed to another commit will
169 be marked with a ? in the blame output. If the
170 blame.markUnblamableLines config option is set, then those lines
171 touched by an ignored commit that we could not attribute to another
172 revision are marked with a *.
173
174 --ignore-revs-file <file>
175 Ignore revisions listed in file, which must be in the same format
176 as an fsck.skipList. This option may be repeated, and these files
177 will be processed after any files specified with the
178 blame.ignoreRevsFile config option. An empty file name, "", will
179 clear the list of revs from previously processed files.
180
181 --color-lines
182 Color line annotations in the default format differently if they
183 come from the same commit as the preceding line. This makes it
184 easier to distinguish code blocks introduced by different commits.
185 The color defaults to cyan and can be adjusted using the
186 color.blame.repeatedLines config option.
187
188 --color-by-age
189 Color line annotations depending on the age of the line in the
190 default format. The color.blame.highlightRecent config option
191 controls what color is used for each range of age.
192
193 -h
194 Show help message.
195
197 git-blame(1)
198
200 Part of the git(1) suite
201
202
203
204Git 2.43.0 11/20/2023 GIT-ANNOTATE(1)