blame

NAME

git-blame - Show what revision and author last modified each line of a filegit-blame - ファイルの各行を最後に修正したリビジョンと作者を表示する

SYNOPSIS概要

git blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-e] [-p] [-w] [--incremental]
	    [-L <range>] [-S <revs-file>] [-M] [-C] [-C] [-C] [--since=<date>]
	    [--progress] [--abbrev=<n>] [<rev> | --contents <file> | --reverse <rev>..<rev>]
	    [--] <file>

DESCRIPTION説明

Annotates each line in the given file with information from the revision which last modified the line. Optionally, start annotating from the given revision.与えられたファイルの各行に、その行を最後に修正したリビジョンからの情報で注釈を付けます。オプションで、与えられたリビジョンから注釈を付け始めます。

When specified one or more times, -L restricts annotation to the requested lines.1回以上指定-Lすると、注釈は要求された行に制限されます。

The origin of lines is automatically followed across whole-file renames (currently there is no option to turn the rename-following off). To follow lines moved from one file to another, or to follow lines that were copied and pasted from another file, etc., see the -C and -M options.行の起点は自動的にファイル全体の名前の変更にまたがって追跡されます(現時点では、名前の変更に続くオプションをオフにするオプションはありません)。あるファイルから別のファイルに移動した行をたどる場合や、別のファイルからコピーして貼り付けた行をたどる場合などには、-Cand -Mオプションを参照してください。

The report does not tell you anything about lines which have been deleted or replaced; you need to use a tool such as git diff or the "pickaxe" interface briefly mentioned in the following paragraph.レポートには、削除または置き換えられた行については何も表示されません。次の段落で簡単に説明されているように、git diffや "pickaxe"インタフェースのようなツールを使う必要があります。

Apart from supporting file annotation, Git also supports searching the development history for when a code snippet occurred in a change. This makes it possible to track when a code snippet was added to a file, moved or copied between files, and eventually deleted or replaced. It works by searching for a text string in the diff. A small example of the pickaxe interface that searches for blame_usage:ファイルの注釈をサポートすることとは別に、Gitはコードスニペットが変更で発生したときの開発履歴の検索もサポートします。これにより、コードスニペットがいつファイルに追加され、ファイル間で移動またはコピーされ、最終的に削除または置き換えられたかを追跡することができます。それはdiffでテキスト文字列を検索することによって機能します。検索つるはしインタフェースの小さな例blame_usage

$ git log --pretty=oneline -S'blame_usage'
5040f17eba15504bad66b14a645bddd9b015ebb7 blame -S <ancestry-file>
ea4c7f9bf69e781dd0cd88d2bccb2bf5cc15c9a7 git-blame: Make the output

OPTIONSオプション

-b

Show blank SHA-1 for boundary commits. This can also be controlled via the blame.blankboundary config option.境界コミットの場合は空白のSHA-1を表示します。これはblame.blankboundaryconfigオプションでも制御できます。

--root - ルート

Do not treat root commits as boundaries. This can also be controlled via the blame.showRoot config option.ルートコミットを境界として扱わないでください。これはblame.showRootconfigオプションでも制御できます。

--show-stats

Include additional statistics at the end of blame output.非難出力の最後に追加の統計を含めます。

-L <start>,<end> -L <開始>、<終了>
-L :<funcname> -L:<funcname>

Annotate only the given line range. May be specified multiple times. Overlapping ranges are allowed.与えられた行範囲だけに注釈を付けます。複数回指定できます。重複範囲は許可されます。

<start> and <end> are optional. “-L <start>” or “-L <start>,” spans from <start> to end of file. “-L ,<end>” spans from start of file to <end>.<start>と<end>はオプションです。“ -L <start>”または“ -L <start>”は、<start>からファイルの終わりまでにわたります。“ -L、<end>”はファイルの先頭から<end>までの範囲です。

<start> and <end> can take one of these forms:<start>と<end>は次のいずれかの形式を取ります。

  • number

    If <start> or <end> is a number, it specifies an absolute line number (lines count from 1).<start>または<end>が数値の場合は、絶対行番号を指定します(1からの行数)。

  • /regex//正規表現/

    This form will use the first line matching the given POSIX regex. If <start> is a regex, it will search from the end of the previous -L range, if any, otherwise from the start of file. If <start> is “^/regex/”, it will search from the start of file. If <end> is a regex, it will search starting at the line given by <start>.このフォームは与えられたPOSIX正規表現にマッチする最初の行を使います。<start>が正規表現の-L場合、前の範囲の末尾から(存在する場合)、それ以外の場合はファイルの先頭から検索します。<start>が“ ^ / regex /”の場合、ファイルの先頭から検索します。<end>が正規表現の場合、<start>で与えられた行から検索します。

  • +offset or -offset+ offsetまたは-offset

    This is only valid for <end> and will specify a number of lines before or after the line given by <start>.これは<end>に対してのみ有効であり、<start>によって与えられた行の前後の行数を指定します。

If “:<funcname>” is given in place of <start> and <end>, it is a regular expression that denotes the range from the first funcname line that matches <funcname>, up to the next funcname line. “:<funcname>” searches from the end of the previous -L range, if any, otherwise from the start of file. “^:<funcname>” searches from the start of file.<start>と<end>の代わりに“:<funcname>”が指定されている場合は、<funcname>と一致する最初のfuncname行から次のfuncname行までの範囲を表す正規表現です。“:<funcname>”は-L、もしあれば前の範囲の終わりから検索し、そうでなければファイルの先頭から検索します。“ ^:<funcname>”はファイルの先頭から検索します。

-l

Show long rev (Default: off).長い回転を表示します(デフォルト:オフ)。

-t

Show raw timestamp (Default: off).生のタイムスタンプを表示します(デフォルト:オフ)。

-S <revs-file>

Use revisions from revs-file instead of calling git-rev-list[1].git-rev-list [1]を呼び出す代わりにrevs-fileからのリビジョンを使用してください。

--reverse <rev>..<rev> --reverse <rev> .. <rev>

Walk history forward instead of backward. Instead of showing the revision in which a line appeared, this shows the last revision in which a line has existed. This requires a range of revision like START..END where the path to blame exists in START. git blame --reverse START is taken as git blame --reverse START..HEAD for convenience.歴史を後方ではなく前方に歩く。行が現れたリビジョンを表示する代わりに、これは行が存在した最後のリビジョンを示します。これには、START ... ENDのように、責任のあるパスがSTARTに存在する場合のように、さまざまな改訂が必要です。便宜上git blame --reverse STARTとられgit blame --reverse START..HEADています。

-p
--porcelain - 磁器

Show in a format designed for machine consumption.機械消費用に設計された形式で表示します。

--line-porcelain - 磁器

Show the porcelain format, but output commit information for each line, not just the first time a commit is referenced. Implies --porcelain.最初のコミットが参照されたときだけでなく、磁器のフォーマットを表示しますが、各行のコミット情報を出力します。含意 - 磁器。

--incremental - 増分

Show the result incrementally in a format designed for machine consumption.機械消費用に設計された形式で結果を少しずつ表示します。

--encoding=<encoding> --encoding = <encoding>

Specifies the encoding used to output author names and commit summaries. Setting it to none makes blame output unconverted data. For more information see the discussion about encoding in the git-log[1] manual page.作成者名の出力と要約のコミットに使用されるエンコードを指定します。これをに設定するとnone、変換されていないデータが非難出力になります。詳細についてはgit-log [1]マニュアルページのエンコーディングに関する議論を参照してください。

--contents <file> --contentnts <ファイル>

When <rev> is not specified, the command annotates the changes starting backwards from the working tree copy. This flag makes the command pretend as if the working tree copy has the contents of the named file (specify - to make the command read from the standard input).<rev>が指定されていない場合、コマンドは作業ツリーのコピーから逆方向に始まる変更に注釈を付けます。このフラグは、ワーキングツリーコピーが指定-されたファイルの内容を持っているかのようにコマンドをふりをします(コマンドを標準入力から読み取らせるように指定します)。

--date <format> --date <フォーマット>

Specifies the format used to output dates. If --date is not provided, the value of the blame.date config variable is used. If the blame.date config variable is also not set, the iso format is used. For supported values, see the discussion of the --date option at git-log[1].日付を出力するために使用されるフォーマットを指定します。--dateが指定されていない場合は、blame.date設定変数の値が使用されます。blame.date構成変数も設定されていない場合は、iso形式が使用されます。サポートされている値については、git-log [1]の --dateオプションの説明を参照してください。

--[no-]progress - 進捗状況

Progress status is reported on the standard error stream by default when it is attached to a terminal. This flag enables progress reporting even if not attached to a terminal. Can’t use --progress together with --porcelain or --incremental.進行状況は、端末に接続されたときにデフォルトで標準エラーストリームに報告されます。このフラグは、端末に接続されていなくても進捗レポートを有効にします。使用することはできません--progressと一緒--porcelain--incremental

-M[<num>] -M [<数>]

Detect moved or copied lines within a file. When a commit moves or copies a block of lines (e.g. the original file has A and then B, and the commit changes it to B and then A), the traditional blame algorithm notices only half of the movement and typically blames the lines that were moved up (i.e. B) to the parent and assigns blame to the lines that were moved down (i.e. A) to the child commit. With this option, both groups of lines are blamed on the parent by running extra passes of inspection.ファイル内の移動またはコピーされた行を検出します。コミットによって行ブロックが移動またはコピーされると(たとえば、元のファイルにA、次にBがあり、コミットによってそれがB、次にAに変更されると)、従来の責任のアルゴリズムは移動の半分だけに気付き、通常上に移動して(つまりB)親に移動し、下に移動した行(つまりA)を子のコミットに非難を割り当てます。このオプションを使用すると、余分な検査パスを実行して、両方のグループの行が親であるとみなされます。

<num> is optional but it is the lower bound on the number of alphanumeric characters that Git must detect as moving/copying within a file for it to associate those lines with the parent commit. The default value is 20.<num>はオプションですが、それらの行を親コミットと関連付けるためにGitがファイル内での移動/コピーとして検出する必要がある英数字の数の下限です。デフォルト値は20です。

-C[<num>] -C [<番号>]

In addition to -M, detect lines moved or copied from other files that were modified in the same commit. This is useful when you reorganize your program and move code around across files. When this option is given twice, the command additionally looks for copies from other files in the commit that creates the file. When this option is given three times, the command additionally looks for copies from other files in any commit.さらに-M、同じコミットで変更された他のファイルから移動またはコピーされた行を検出します。これは、プログラムを再編成してファイル間でコードを移動するときに役立ちます。このオプションを2回指定すると、コマンドはファイルを作成するコミット内で他のファイルからのコピーをさらに検索します。このオプションが3回与えられると、このコマンドは任意のコミットで他のファイルからのコピーをさらに検索します。

<num> is optional but it is the lower bound on the number of alphanumeric characters that Git must detect as moving/copying between files for it to associate those lines with the parent commit. And the default value is 40. If there are more than one -C options given, the <num> argument of the last -C will take effect.<num>はオプションですが、Gitがそれらの行を親コミットと関連付けるためにファイル間の移動/コピーとして検出しなければならない英数字の数の下限です。デフォルト値は40です。複数の-Cオプションが指定されている場合は、最後の<num>引数が-C有効になります。

-h

Show help message.ヘルプメッセージを表示します。

-c

Use the same output mode as git-annotate[1] (Default: off).git-annotate [1]と同じ出力モードを使用します(デフォルト:オフ)。

--score-debug

Include debugging information related to the movement of lines between files (see -C) and lines moved within a file (see -M). The first number listed is the score. This is the number of alphanumeric characters detected as having been moved between or within files. This must be above a certain threshold for git blame to consider those lines of code to have been moved.ファイル間の-C行の移動(を参照)およびファイル内を移動した行(を参照)に関連するデバッグ情報を含めます-M。リストの最初の数字はスコアです。これは、ファイル間またはファイル内で移動されたと検出された英数字の数です。これらのコード行が移動されたと見なすには、git blameにとってこれは一定のしきい値を超えている必要があります。

-f
--show-name - ショー名

Show the filename in the original commit. By default the filename is shown if there is any line that came from a file with a different name, due to rename detection.元のコミットでファイル名を表示します。デフォルトでは、名前変更検出のために、別の名前のファイルからの行がある場合は、ファイル名が表示されます。

-n
--show-number - ショー番号

Show the line number in the original commit (Default: off).元のコミットで行番号を表示します(デフォルト:off)。

-s

Suppress the author name and timestamp from the output.出力から作成者名とタイムスタンプを抑制します。

-e
--show-email

Show the author email instead of author name (Default: off). This can also be controlled via the blame.showEmail config option.著者名の代わりに著者のEメールを表示します(デフォルト:off)。これはblame.showEmailconfigオプションでも制御できます。

-w

Ignore whitespace when comparing the parent’s version and the child’s to find where the lines came from.親のバージョンと子のバージョンを比較して行がどこから来たのかを見つけるときに空白を無視します。

--abbrev=<n> --abbrev = <n>

Instead of using the default 7+1 hexadecimal digits as the abbreviated object name, use <n>+1 digits. Note that 1 column is used for a caret to mark the boundary commit.省略時のオブジェクト名としてデフォルトの7 + 1桁の16進数を使用する代わりに、<n> +1桁を使用してください。1列は、境界コミットをマークするためのキャレットとして使用されます。

THE PORCELAIN FORMAT陶磁器のフォーマット

In this format, each line is output after a header; the header at the minimum has the first line which has:このフォーマットでは、各行はヘッダーの後に出力されます。最小のヘッダーには、最初の行があります。

  • 40-byte SHA-1 of the commit the line is attributed to;その行が属するコミットの40バイトのSHA-1。

  • the line number of the line in the original file;元のファイルの行番号

  • the line number of the line in the final file;最終ファイルの行番号

  • on a line that starts a group of lines from a different commit than the previous one, the number of lines in this group. On subsequent lines this field is absent.前のコミットとは異なるコミットから行のグループを開始する行で、このグループの行数。その後の行では、このフィールドはありません。

This header line is followed by the following information at least once for each commit:このヘッダー行の後には、コミットごとに少なくとも一度は以下の情報が続きます。

  • the author name ("author"), email ("author-mail"), time ("author-time"), and time zone ("author-tz"); similarly for committer.著者名( "author")、電子メール( "author-mail")、時間( "author-time")、およびタイムゾーン( "author-tz")。コミッターについても同様です。

  • the filename in the commit that the line is attributed to.その行が属するコミットのファイル名。

  • the first line of the commit log message ("summary").コミットログメッセージの最初の行( "summary")。

The contents of the actual line is output after the above header, prefixed by a TAB. This is to allow adding more header elements later.実際の行の内容は、上記のヘッダーの後ろにTABを先頭に付けて出力されます。これは後でさらにヘッダ要素を追加できるようにするためです。

The porcelain format generally suppresses commit information that has already been seen. For example, two lines that are blamed to the same commit will both be shown, but the details for that commit will be shown only once. This is more efficient, but may require more state be kept by the reader. The --line-porcelain option can be used to output full commit information for each line, allowing simpler (but less efficient) usage like:磁器フォーマットは一般的にすでに見られたコミット情報を抑制します。例えば、同じコミットのせいにされている2行は両方とも表示されますが、そのコミットの詳細は1回しか表示されません。これはより効率的ですが、より多くの状態をリーダーが保持する必要があるかもしれません。この--line-porcelainオプションを使用すると、各行について完全なコミット情報を出力できます。これにより、次のようなより単純な(ただし効率が低い)使用法が可能になります。

# count the number of lines attributed to each author
git blame --line-porcelain file |
sed -n 's/^author //p' |
sort | uniq -c | sort -rn

SPECIFYING RANGES範囲を指定する

Unlike git blame and git annotate in older versions of git, the extent of the annotation can be limited to both line ranges and revision ranges. The -L option, which limits annotation to a range of lines, may be specified multiple times.gitの古いバージョンのgit blamegit annotateとは異なり、注釈の範囲は行範囲とリビジョン範囲の両方に制限できます。-L行の範囲に注釈を制限オプションは、複数回指定することができます。

When you are interested in finding the origin for lines 40-60 for file foo, you can use the -L option like so (they mean the same thing — both ask for 21 lines starting at line 40):ファイルの40行目から60行目の起点を探したい場合はfoo、次の-Lようにオプションを使用できます(それらは同じことを意味します - 両方とも40行目から始まる21行を要求します)。

git blame -L 40,60 foo
git blame -L 40,+21 foo

Also you can use a regular expression to specify the line range:また、正規表現を使って行の範囲を指定することもできます。

git blame -L '/^sub hello {/,/^}$/' foo

which limits the annotation to the body of the hello subroutine.これは注釈をhelloサブルーチンの本体に限定します。

When you are not interested in changes older than version v2.6.18, or changes older than 3 weeks, you can use revision range specifiers similar to git rev-list:バージョンv2.6.18より前の変更、または3週間より前の変更に興味がない場合は、git rev-listに似たリビジョン範囲指定子を使用できます。

git blame v2.6.18.. -- foo
git blame --since=3.weeks -- foo

When revision range specifiers are used to limit the annotation, lines that have not changed since the range boundary (either the commit v2.6.18 or the most recent commit that is more than 3 weeks old in the above example) are blamed for that range boundary commit.注釈を制限するためにリビジョン範囲指定子が使用されている場合、範囲の境界(上記の例ではcommit v2.6.18または3週間以上前の最新のコミット)以降変更されていない行はその範囲の境界のせいにされます。コミット。

A particularly useful way is to see if an added file has lines created by copy-and-paste from existing files. Sometimes this indicates that the developer was being sloppy and did not refactor the code properly. You can first find the commit that introduced the file with:特に便利な方法は、追加されたファイルに既存のファイルからコピー&ペーストで作成された行があるかどうかを確認することです。時々これは開発者がずさんでいてコードを適切にリファクタリングしていなかったことを示します。最初にファイルを導入したコミットを見つけることができます。

git log --diff-filter=A --pretty=short -- foo

and then annotate the change between the commit and its parents, using commit^! notation:そして、次のcommit^!表記を使ってコミットとその親の間の変更に注釈を付けます。

git blame -C -C -f $commit^! -- foo

INCREMENTAL OUTPUTインクリメンタル出力

When called with --incremental option, the command outputs the result as it is built. The output generally will talk about lines touched by more recent commits first (i.e. the lines will be annotated out of order) and is meant to be used by interactive viewers.--incrementaloptionを付けて呼び出すと、コマンドはビルド時の結果を出力します。出力は一般的に、最近のコミットによって最初に触れられた行について話します(すなわち、行は順不同で注釈を付けられます)そして対話的な視聴者によって使用されることを意味します。

The output format is similar to the Porcelain format, but it does not contain the actual lines from the file that is being annotated.出力フォーマットはPorcelainフォーマットと似ていますが、注釈を付けられているファイルの実際の行は含まれていません。

  1. Each blame entry always starts with a line of:各非難エントリは常に次の行で始まります。

    <40-byte hex sha1> <sourceline> <resultline> <num_lines>

    Line numbers count from 1.行番号は1から数えます。

  2. The first time that a commit shows up in the stream, it has various other information about it printed out with a one-word tag at the beginning of each line describing the extra commit information (author, email, committer, dates, summary, etc.).コミットがストリームに初めて表示されるときには、コミットに関するその他の情報(作者、電子メール、コミッター、日付、要約など)を記述する1行のタグが各行の先頭に印刷されています。 。)

  3. Unlike the Porcelain format, the filename information is always given and terminates the entry:Porcelainフォーマットとは異なり、ファイル名情報は常に与えられ、エントリを終了させます。

    "filename" <whitespace-quoted-filename-goes-here>

    and thus it is really quite easy to parse for some line- and word-oriented parser (which should be quite natural for most scripting languages).したがって、行指向および単語指向のパーサー(ほとんどのスクリプト言語にとっては非常に自然なもの)を解析するのは非常に簡単です。

    Note For people who do parsing: to make it more robust, just ignore any lines between the first and last one ("<sha1>" and "filename" lines) where you do not recognize the tag words (or care about that particular one) at the beginning of the "extended information" lines. That way, if there is ever added information (like the commit encoding or extended commit commentary), a blame viewer will not care. 構文解析をする人々のために:それをより強固にするために、最初と最後の行の間のタグ行を認識しない行( "<sha1>"と "filename"行)を無視してください。 「拡張情報」行の先頭にあります。そうすれば、追加された情報(コミットエンコーディングや拡張コミットコメンタリーなど)があったとしても、非難ビューアは気にしません。

MAPPING AUTHORSマッピング作者

If the file .mailmap exists at the toplevel of the repository, or at the location pointed to by the mailmap.file or mailmap.blob configuration options, it is used to map author and committer names and email addresses to canonical real names and email addresses.ファイル.mailmapがリポジトリの最上位レベル、またはmailmap.fileまたはmailmap.blob設定オプションで指定された場所に存在する場合は、作成者およびコミッターの名前と電子メールアドレスを正規の実名と電子メールアドレスにマッピングするために使用されます。

In the simple form, each line in the file consists of the canonical real name of an author, whitespace, and an email address used in the commit (enclosed by < and >) to map to the name. For example:単純な形式では、ファイル内の各行は、作成者の正規の実名、空白、および名前にマップするためにコミットで使用される電子メールアドレス(<および>で囲まれています)で構成されています。例えば:

Proper Name <commit@email.xx>

The more complex forms are:より複雑な形式は次のとおりです。

<proper@email.xx> <commit@email.xx>

which allows mailmap to replace only the email part of a commit, and:これにより、mailmapはコミットのEメール部分のみを置き換えることができます。

Proper Name <proper@email.xx> <commit@email.xx>

which allows mailmap to replace both the name and the email of a commit matching the specified commit email address, and:これにより、mailmapは、指定されたコミットEメールアドレスに一致するコミットの名前とEメールの両方を置き換えることができます。

Proper Name <proper@email.xx> Commit Name <commit@email.xx>

which allows mailmap to replace both the name and the email of a commit matching both the specified commit name and email address.これにより、mailmapは、指定されたコミット名とEメールアドレスの両方に一致するコミットの名前とEメールの両方を置き換えることができます。

Example 1: Your history contains commits by two authors, Jane and Joe, whose names appear in the repository under several forms:例1:あなたの履歴には2人の作者JaneとJoeによるコミットが含まれています。それらの名前はいくつかの形式でリポジトリに表示されます。

Joe Developer <joe@example.com>
Joe R. Developer <joe@example.com>
Jane Doe <jane@example.com>
Jane Doe <jane@laptop.(none)>
Jane D. <jane@desktop.(none)>

Now suppose that Joe wants his middle name initial used, and Jane prefers her family name fully spelled out. A proper .mailmap file would look like:ここで、Joeが自分のミドルネームの頭文字を使用したいとし、Janeが彼女の姓を完全に綴ったものを好むとします。適切な.mailmapファイルは次のようになります。

Jane Doe         <jane@desktop.(none)>
Joe R. Developer <joe@example.com>

Note how there is no need for an entry for <jane@laptop.(none)>, because the real name of that author is already correct.<jane@laptop.(none)>その作者の本名はすでに正しいので、のためのエントリが必要ないことに注意してください。

Example 2: Your repository contains commits from the following authors:例2:あなたのリポジトリには、以下の作者からのコミットが含まれています。

nick1 <bugs@company.xx>
nick2 <bugs@company.xx>
nick2 <nick2@company.xx>
santa <me@company.xx>
claus <me@company.xx>
CTO <cto@coompany.xx>

Then you might want a .mailmap file that looks like:それならあなたは.mailmap次のようなファイルが欲しいかもしれません:

<cto@company.xx>                       <cto@coompany.xx>
Some Dude <some@dude.xx>         nick1 <bugs@company.xx>
Other Author <other@author.xx>   nick2 <bugs@company.xx>
Other Author <other@author.xx>         <nick2@company.xx>
Santa Claus <santa.claus@northpole.xx> <me@company.xx>

Use hash # for comments that are either on their own line, or after the email address.自分の行にある、またはEメールアドレスの後にあるコメントには、ハッシュを使用してください。

SEE ALSO関連項目

git-annotate[1]git-annotate [1]

GIT

Part of the git[1] suite一部のgit [1]スイート

関連記事

スポンサーリンク

Android Maps API Keyを取得する方法 Google Mapsを利用する

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る