1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.4.5" />
7 <title>git-blame(
1)
</title>
8 <style type=
"text/css">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.5em;
116 margin-bottom: 1.5em;
118 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
119 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
120 div
.admonitionblock
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.5em;
129 div
.content
{ /* Block element content. */
133 /* Block element titles. */
134 div
.title
, caption
.title
{
136 font-family: sans-serif
;
140 margin-bottom: 0.5em;
146 td div
.title:first-child
{
149 div
.content div
.title:first-child
{
152 div
.content
+ div
.title
{
156 div
.sidebarblock
> div
.content
{
158 border: 1px solid silver
;
162 div
.listingblock
> div
.content
{
163 border: 1px solid silver
;
172 div
.quoteblock
> div
.attribution
{
181 div
.verseblock
> div
.content
{
184 div
.verseblock
> div
.attribution
{
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div
.verseblock
+ div
.attribution
{
193 div
.admonitionblock
.icon
{
197 text-decoration: underline
;
199 padding-right: 0.5em;
201 div
.admonitionblock td
.content
{
203 border-left: 2px solid silver
;
206 div
.exampleblock
> div
.content
{
207 border-left: 2px solid silver
;
211 div
.imageblock div
.content
{ padding-left: 0; }
212 span
.image img
{ border-style: none
; }
213 a
.image:visited
{ color: white
; }
217 margin-bottom: 0.8em;
230 list-style-position: outside
;
233 list-style-type: decimal
;
236 list-style-type: lower-alpha
;
239 list-style-type: upper-alpha
;
242 list-style-type: lower-roman
;
245 list-style-type: upper-roman
;
248 div
.compact ul
, div
.compact ol
,
249 div
.compact p
, div
.compact p
,
250 div
.compact div
, div
.compact div
{
252 margin-bottom: 0.1em;
255 div
.tableblock
> table
{
256 border: 3px solid
#527bbd;
259 font-family: sans-serif
;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div
.tableblock
> table
[frame
="void"] {
275 div
.tableblock
> table
[frame
="hsides"] {
276 border-left-style: none
;
277 border-right-style: none
;
279 div
.tableblock
> table
[frame
="vsides"] {
280 border-top-style: none
;
281 border-bottom-style: none
;
287 margin-bottom: 0.8em;
290 padding-bottom: 15px;
292 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
298 padding-right: 0.8em;
304 div
.hdlist
.compact tr
{
314 div#footer-badges
{ display: none
; }
319 font-family: sans-serif
;
323 margin-bottom: 0.1em;
326 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
342 /* Overrides for manpage documents */
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver
;
347 border-bottom: 2px solid silver
;
357 div#toc
{ display: none
; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div
.sidebar-content
{
364 border: 1px solid silver
;
367 div
.sidebar-title
, div
.image-title
{
369 font-family: sans-serif
;
372 margin-bottom: 0.5em;
375 div
.listingblock div
.content
{
376 border: 1px solid silver
;
381 div
.quoteblock-attribution
{
386 div
.verseblock-content
{
389 div
.verseblock-attribution
{
394 div
.exampleblock-content
{
395 border-left: 2px solid silver
;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc
a:visited
{ color: blue
; }
406 git-blame(
1) Manual Page
409 <div class=
"sectionbody">
411 Show what revision and author last modified each line of a file
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"verseblock">
418 <div class=
"verseblock-content"><em>git blame
</em> [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-e] [-p] [-w] [--incremental] [-L n,m]
419 [-S
<revs-file
>] [-M] [-C] [-C] [-C] [--since=
<date
>] [--abbrev=
<n
>]
420 [
<rev
> | --contents
<file
> | --reverse
<rev
>] [--]
<file
></div>
421 <div class=
"verseblock-attribution">
424 <h2 id=
"_description">DESCRIPTION
</h2>
425 <div class=
"sectionbody">
426 <div class=
"paragraph"><p>Annotates each line in the given file with information from the revision which
427 last modified the line. Optionally, start annotating from the given revision.
</p></div>
428 <div class=
"paragraph"><p>The command can also limit the range of lines annotated.
</p></div>
429 <div class=
"paragraph"><p>The report does not tell you anything about lines which have been deleted or
430 replaced; you need to use a tool such as
<em>git diff
</em> or the
"pickaxe"
431 interface briefly mentioned in the following paragraph.
</p></div>
432 <div class=
"paragraph"><p>Apart from supporting file annotation, git also supports searching the
433 development history for when a code snippet occurred in a change. This makes it
434 possible to track when a code snippet was added to a file, moved or copied
435 between files, and eventually deleted or replaced. It works by searching for
436 a text string in the diff. A small example:
</p></div>
437 <div class=
"listingblock">
438 <div class=
"content">
439 <pre><tt>$ git log --pretty=oneline -S'blame_usage'
440 5040f17eba15504bad66b14a645bddd9b015ebb7 blame -S
<ancestry-file
>
441 ea4c7f9bf69e781dd0cd88d2bccb2bf5cc15c9a7 git-blame: Make the output
</tt></pre>
444 <h2 id=
"_options">OPTIONS
</h2>
445 <div class=
"sectionbody">
446 <div class=
"dlist"><dl>
452 Show blank SHA-
1 for boundary commits. This can also
453 be controlled via the
<tt>blame.blankboundary
</tt> config option.
461 Do not treat root commits as boundaries. This can also be
462 controlled via the
<tt>blame.showroot
</tt> config option.
470 Include additional statistics at the end of blame output.
474 -L
<start
>,
<end
>
478 Annotate only the given line range.
<start
> and
<end
> can take
481 <div class=
"ulist"><ul>
486 <div class=
"paragraph"><p>If
<start
> or
<end
> is a number, it specifies an
487 absolute line number (lines count from
1).
</p></div>
493 <div class=
"paragraph"><p>This form will use the first line matching the given
494 POSIX regex. If
<end
> is a regex, it will search
495 starting at the line given by
<start
>.
</p></div>
501 <div class=
"paragraph"><p>This is only valid for
<end
> and will specify a number
502 of lines before or after the line given by
<start
>.
</p></div>
511 Show long rev (Default: off).
519 Show raw timestamp (Default: off).
527 Use revisions from revs-file instead of calling
<a href=
"git-rev-list.html">git-rev-list(
1)
</a>.
535 Walk history forward instead of backward. Instead of showing
536 the revision in which a line appeared, this shows the last
537 revision in which a line has existed. This requires a range of
538 revision like START..END where the path to blame exists in
550 Show in a format designed for machine consumption.
558 Show the porcelain format, but output commit information for
559 each line, not just the first time a commit is referenced.
568 Show the result incrementally in a format designed for
573 --encoding=
<encoding
>
577 Specifies the encoding used to output author names
578 and commit summaries. Setting it to
<tt>none
</tt> makes blame
579 output unconverted data. For more information see the
580 discussion about encoding in the
<a href=
"git-log.html">git-log(
1)
</a>
585 --contents
<file
>
589 When
<rev
> is not specified, the command annotates the
590 changes starting backwards from the working tree copy.
591 This flag makes the command pretend as if the working
592 tree copy has the contents of the named file (specify
593 <tt>-
</tt> to make the command read from the standard input).
597 --date
<format
>
601 The value is one of the following alternatives:
602 {relative,local,default,iso,rfc,short}. If --date is not
603 provided, the value of the blame.date config variable is
604 used. If the blame.date config variable is also not set, the
605 iso format is used. For more information, See the discussion
606 of the --date option at
<a href=
"git-log.html">git-log(
1)
</a>.
614 Detect moved or copied lines within a file. When a commit
615 moves or copies a block of lines (e.g. the original file
616 has A and then B, and the commit changes it to B and then
617 A), the traditional
<em>blame
</em> algorithm notices only half of
618 the movement and typically blames the lines that were moved
619 up (i.e. B) to the parent and assigns blame to the lines that
620 were moved down (i.e. A) to the child commit. With this
621 option, both groups of lines are blamed on the parent by
622 running extra passes of inspection.
624 <div class=
"paragraph"><p><num
> is optional but it is the lower bound on the number of
625 alphanumeric characters that git must detect as moving/copying
626 within a file for it to associate those lines with the parent
627 commit. The default value is
20.
</p></div>
634 In addition to
<tt>-M
</tt>, detect lines moved or copied from other
635 files that were modified in the same commit. This is
636 useful when you reorganize your program and move code
637 around across files. When this option is given twice,
638 the command additionally looks for copies from other
639 files in the commit that creates the file. When this
640 option is given three times, the command additionally
641 looks for copies from other files in any commit.
643 <div class=
"paragraph"><p><num
> is optional but it is the lower bound on the number of
644 alphanumeric characters that git must detect as moving/copying
645 between files for it to associate those lines with the parent
646 commit. And the default value is
40. If there are more than one
647 <tt>-C
</tt> options given, the
<num
> argument of the last
<tt>-C
</tt> will
648 take effect.
</p></div>
666 Use the same output mode as
<a href=
"git-annotate.html">git-annotate(
1)
</a> (Default: off).
674 Include debugging information related to the movement of
675 lines between files (see
<tt>-C
</tt>) and lines moved within a
676 file (see
<tt>-M
</tt>). The first number listed is the score.
677 This is the number of alphanumeric characters detected
678 as having been moved between or within files. This must be above
679 a certain threshold for
<em>git blame
</em> to consider those lines
680 of code to have been moved.
691 Show the filename in the original commit. By default
692 the filename is shown if there is any line that came from a
693 file with a different name, due to rename detection.
704 Show the line number in the original commit (Default: off).
712 Suppress the author name and timestamp from the output.
723 Show the author email instead of author name (Default: off).
731 Ignore whitespace when comparing the parent
’s version and
732 the child
’s to find where the lines came from.
740 Instead of using the default
7+
1 hexadecimal digits as the
741 abbreviated object name, use
<n
>+
1 digits. Note that
1 column
742 is used for a caret to mark the boundary commit.
747 <h2 id=
"_the_porcelain_format">THE PORCELAIN FORMAT
</h2>
748 <div class=
"sectionbody">
749 <div class=
"paragraph"><p>In this format, each line is output after a header; the
750 header at the minimum has the first line which has:
</p></div>
751 <div class=
"ulist"><ul>
754 40-byte SHA-
1 of the commit the line is attributed to;
759 the line number of the line in the original file;
764 the line number of the line in the final file;
769 on a line that starts a group of lines from a different
770 commit than the previous one, the number of lines in this
771 group. On subsequent lines this field is absent.
775 <div class=
"paragraph"><p>This header line is followed by the following information
776 at least once for each commit:
</p></div>
777 <div class=
"ulist"><ul>
780 the author name (
"author"), email (
"author-mail"), time
781 (
"author-time"), and timezone (
"author-tz"); similarly
787 the filename in the commit that the line is attributed to.
792 the first line of the commit log message (
"summary").
796 <div class=
"paragraph"><p>The contents of the actual line is output after the above
797 header, prefixed by a TAB. This is to allow adding more
798 header elements later.
</p></div>
799 <div class=
"paragraph"><p>The porcelain format generally suppresses commit information that has
800 already been seen. For example, two lines that are blamed to the same
801 commit will both be shown, but the details for that commit will be shown
802 only once. This is more efficient, but may require more state be kept by
803 the reader. The
<tt>--line-porcelain
</tt> option can be used to output full
804 commit information for each line, allowing simpler (but less efficient)
805 usage like:
</p></div>
806 <div class=
"literalblock">
807 <div class=
"content">
808 <pre><tt># count the number of lines attributed to each author
809 git blame --line-porcelain file |
810 sed -n 's/^author //p' |
811 sort | uniq -c | sort -rn
</tt></pre>
814 <h2 id=
"_specifying_ranges">SPECIFYING RANGES
</h2>
815 <div class=
"sectionbody">
816 <div class=
"paragraph"><p>Unlike
<em>git blame
</em> and
<em>git annotate
</em> in older versions of git, the extent
817 of the annotation can be limited to both line ranges and revision
818 ranges. When you are interested in finding the origin for
819 lines
40-
60 for file
<tt>foo
</tt>, you can use the
<tt>-L
</tt> option like so
820 (they mean the same thing
 — both ask for
21 lines starting at
822 <div class=
"literalblock">
823 <div class=
"content">
824 <pre><tt>git blame -L
40,
60 foo
825 git blame -L
40,+
21 foo
</tt></pre>
827 <div class=
"paragraph"><p>Also you can use a regular expression to specify the line range:
</p></div>
828 <div class=
"literalblock">
829 <div class=
"content">
830 <pre><tt>git blame -L '/^sub hello {/,/^}$/' foo
</tt></pre>
832 <div class=
"paragraph"><p>which limits the annotation to the body of the
<tt>hello
</tt> subroutine.
</p></div>
833 <div class=
"paragraph"><p>When you are not interested in changes older than version
834 v2.6
.18, or changes older than
3 weeks, you can use revision
835 range specifiers similar to
<em>git rev-list
</em>:
</p></div>
836 <div class=
"literalblock">
837 <div class=
"content">
838 <pre><tt>git blame v2.6
.18.. -- foo
839 git blame --since=
3.weeks -- foo
</tt></pre>
841 <div class=
"paragraph"><p>When revision range specifiers are used to limit the annotation,
842 lines that have not changed since the range boundary (either the
843 commit v2.6
.18 or the most recent commit that is more than
3
844 weeks old in the above example) are blamed for that range
845 boundary commit.
</p></div>
846 <div class=
"paragraph"><p>A particularly useful way is to see if an added file has lines
847 created by copy-and-paste from existing files. Sometimes this
848 indicates that the developer was being sloppy and did not
849 refactor the code properly. You can first find the commit that
850 introduced the file with:
</p></div>
851 <div class=
"literalblock">
852 <div class=
"content">
853 <pre><tt>git log --diff-filter=A --pretty=short -- foo
</tt></pre>
855 <div class=
"paragraph"><p>and then annotate the change between the commit and its
856 parents, using
<tt>commit
^!
</tt> notation:
</p></div>
857 <div class=
"literalblock">
858 <div class=
"content">
859 <pre><tt>git blame -C -C -f $commit^! -- foo
</tt></pre>
862 <h2 id=
"_incremental_output">INCREMENTAL OUTPUT
</h2>
863 <div class=
"sectionbody">
864 <div class=
"paragraph"><p>When called with
<tt>--incremental
</tt> option, the command outputs the
865 result as it is built. The output generally will talk about
866 lines touched by more recent commits first (i.e. the lines will
867 be annotated out of order) and is meant to be used by
868 interactive viewers.
</p></div>
869 <div class=
"paragraph"><p>The output format is similar to the Porcelain format, but it
870 does not contain the actual lines from the file that is being
872 <div class=
"olist arabic"><ol class=
"arabic">
875 Each blame entry always starts with a line of:
877 <div class=
"literalblock">
878 <div class=
"content">
879 <pre><tt><40-byte hex sha1
> <sourceline
> <resultline
> <num_lines
></tt></pre>
881 <div class=
"paragraph"><p>Line numbers count from
1.
</p></div>
885 The first time that a commit shows up in the stream, it has various
886 other information about it printed out with a one-word tag at the
887 beginning of each line describing the extra commit information (author,
888 email, committer, dates, summary, etc.).
893 Unlike the Porcelain format, the filename information is always
894 given and terminates the entry:
896 <div class=
"literalblock">
897 <div class=
"content">
898 <pre><tt>"filename" <whitespace-quoted-filename-goes-here
></tt></pre>
900 <div class=
"paragraph"><p>and thus it is really quite easy to parse for some line- and word-oriented
901 parser (which should be quite natural for most scripting languages).
</p></div>
902 <div class=
"admonitionblock">
905 <div class=
"title">Note
</div>
907 <td class=
"content">For people who do parsing: to make it more robust, just ignore any
908 lines between the first and last one (
"<sha1>" and
"filename" lines)
909 where you do not recognize the tag words (or care about that particular
910 one) at the beginning of the
"extended information" lines. That way, if
911 there is ever added information (like the commit encoding or extended
912 commit commentary), a blame viewer will not care.
</td>
918 <h2 id=
"_mapping_authors">MAPPING AUTHORS
</h2>
919 <div class=
"sectionbody">
920 <div class=
"paragraph"><p>If the file
<tt>.mailmap
</tt> exists at the toplevel of the repository, or at
921 the location pointed to by the mailmap.file configuration option, it
922 is used to map author and committer names and email addresses to
923 canonical real names and email addresses.
</p></div>
924 <div class=
"paragraph"><p>In the simple form, each line in the file consists of the canonical
925 real name of an author, whitespace, and an email address used in the
926 commit (enclosed by
<em><</em> and
<em>></em>) to map to the name. For example:
</p></div>
927 <div class=
"literalblock">
928 <div class=
"content">
929 <pre><tt>Proper Name
<commit@email.xx
></tt></pre>
931 <div class=
"paragraph"><p>The more complex forms are:
</p></div>
932 <div class=
"literalblock">
933 <div class=
"content">
934 <pre><tt><proper@email.xx
> <commit@email.xx
></tt></pre>
936 <div class=
"paragraph"><p>which allows mailmap to replace only the email part of a commit, and:
</p></div>
937 <div class=
"literalblock">
938 <div class=
"content">
939 <pre><tt>Proper Name
<proper@email.xx
> <commit@email.xx
></tt></pre>
941 <div class=
"paragraph"><p>which allows mailmap to replace both the name and the email of a
942 commit matching the specified commit email address, and:
</p></div>
943 <div class=
"literalblock">
944 <div class=
"content">
945 <pre><tt>Proper Name
<proper@email.xx
> Commit Name
<commit@email.xx
></tt></pre>
947 <div class=
"paragraph"><p>which allows mailmap to replace both the name and the email of a
948 commit matching both the specified commit name and email address.
</p></div>
949 <div class=
"paragraph"><p>Example
1: Your history contains commits by two authors, Jane
950 and Joe, whose names appear in the repository under several forms:
</p></div>
951 <div class=
"listingblock">
952 <div class=
"content">
953 <pre><tt>Joe Developer
<joe@example.com
>
954 Joe R. Developer
<joe@example.com
>
955 Jane Doe
<jane@example.com
>
956 Jane Doe
<jane@laptop.(none)
>
957 Jane D.
<jane@desktop.(none)
></tt></pre>
959 <div class=
"paragraph"><p>Now suppose that Joe wants his middle name initial used, and Jane
960 prefers her family name fully spelled out. A proper
<tt>.mailmap
</tt> file
961 would look like:
</p></div>
962 <div class=
"listingblock">
963 <div class=
"content">
964 <pre><tt>Jane Doe
<jane@desktop.(none)
>
965 Joe R. Developer
<joe@example.com
></tt></pre>
967 <div class=
"paragraph"><p>Note how there is no need for an entry for
<<a href=
"mailto:jane@laptop">jane@laptop
</a>.(none)
>, because the
968 real name of that author is already correct.
</p></div>
969 <div class=
"paragraph"><p>Example
2: Your repository contains commits from the following
971 <div class=
"listingblock">
972 <div class=
"content">
973 <pre><tt>nick1
<bugs@company.xx
>
974 nick2
<bugs@company.xx
>
975 nick2
<nick2@company.xx
>
976 santa
<me@company.xx
>
977 claus
<me@company.xx
>
978 CTO
<cto@coompany.xx
></tt></pre>
980 <div class=
"paragraph"><p>Then you might want a
<tt>.mailmap
</tt> file that looks like:
</p></div>
981 <div class=
"listingblock">
982 <div class=
"content">
983 <pre><tt><cto@company.xx
> <cto@coompany.xx
>
984 Some Dude
<some@dude.xx
> nick1
<bugs@company.xx
>
985 Other Author
<other@author.xx
> nick2
<bugs@company.xx
>
986 Other Author
<other@author.xx
> <nick2@company.xx
>
987 Santa Claus
<santa.claus@northpole.xx
> <me@company.xx
></tt></pre>
989 <div class=
"paragraph"><p>Use hash
<em>#
</em> for comments that are either on their own line, or after
990 the email address.
</p></div>
992 <h2 id=
"_see_also">SEE ALSO
</h2>
993 <div class=
"sectionbody">
994 <div class=
"paragraph"><p><a href=
"git-annotate.html">git-annotate(
1)
</a></p></div>
996 <h2 id=
"_git">GIT
</h2>
997 <div class=
"sectionbody">
998 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1001 <div id=
"footer-text">
1002 Last updated
2011-
05-
23 23:
05:
02 UTC