diff

NAME

git-diff - Show changes between commits, commit and working tree, etcgit-diff - コミット、コミットと作業ツリーなどの間の変更を表示する

SYNOPSIS概要

git diff [<options>] [<commit>] [--] [<path>…​]
git diff [<options>] --cached [<commit>] [--] [<path>…​]
git diff [<options>] <commit> <commit> [--] [<path>…​]
git diff [<options>] <blob> <blob>
git diff [<options>] --no-index [--] <path> <path>

DESCRIPTION説明

Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, changes between two blob objects, or changes between two files on disk.作業ツリーとインデックスまたはツリー間の変更、インデックスとツリー間の変更、2つのツリー間の変更、2つのBLOBオブジェクト間の変更、またはディスク上の2つのファイル間の変更を表示します。

git diff [<options>] [--] [<path>…​] git diff [<オプション>] [ - ] [<パス>…]

This form is to view the changes you made relative to the index (staging area for the next commit). In other words, the differences are what you could tell Git to further add to the index but you still haven’t. You can stage these changes by using git-add[1].このフォームは、インデックス(次のコミットのためのステージング領域)に対して行った変更を表示するためのものです。言い換えれば、違いはGitにさらにインデックスを追加するよう指示することができますが、まだ違います。git-add [1]を使ってこれらの変更を段階的に行うことができます。

git diff [<options>] --no-index [--] <path> <path> git diff [<オプション>] --no-index [ - ] <パス> <パス>

This form is to compare the given two paths on the filesystem. You can omit the --no-index option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git.この形式はファイルシステム上の与えられた2つのパスを比較するためのものです。--no-indexGitによって制御され、少なくとも1つのパスが作業ツリーの外側を指す作業ツリーでコマンドを実行する場合、またはGitによって制御される作業ツリーの外側でコマンドを実行する場合は、このオプションを省略できます。

git diff [<options>] --cached [<commit>] [--] [<path>…​] git diff [<オプション>] --cached [<コミット>] [ - ] [<パス>…]

This form is to view the changes you staged for the next commit relative to the named <commit>. Typically you would want comparison with the latest commit, so if you do not give <commit>, it defaults to HEAD. If HEAD does not exist (e.g. unborn branches) and <commit> is not given, it shows all staged changes. --staged is a synonym of --cached.このフォームは、名前付きの<commit>を基準にして次のコミットのためにステージングした変更を表示します。通常は最新のコミットと比較したいので、<commit>を指定しないと、デフォルトはHEADになります。もしHEADが存在せず(例えば、まだ生まれていないブランチ)、<commit>が与えられていない場合は、段階的な変更をすべて表示します。--stagedは--cachedの同義語です。

git diff [<options>] <commit> [--] [<path>…​] git diff [<オプション>] <コミット> [ - ] [<パス>…]

This form is to view the changes you have in your working tree relative to the named <commit>. You can use HEAD to compare it with the latest commit, or a branch name to compare with the tip of a different branch.このフォームは、名前付きの<commit>に対する作業ツリーの変更を表示するためのものです。最新のコミットと比較するためにHEADを使用することも、別のブランチの先端と比較するためにブランチ名を使用することもできます。

git diff [<options>] <commit> <commit> [--] [<path>…​] git diff [<オプション>] <コミット> <コミット> [ - ] [<パス>…]

This is to view the changes between two arbitrary <commit>.これは任意の2つの<commit>間の変更を見るためです。

git diff [<options>] <commit>..<commit> [--] [<path>…​] git diff [<オプション>] <コミット> .. <コミット> [ - ] [<パス>…]

This is synonymous to the previous form. If <commit> on one side is omitted, it will have the same effect as using HEAD instead.これは前の形式と同義です。片側の<commit>が省略された場合、代わりにHEADを使用した場合と同じ効果があります。

git diff [<options>] <commit>...<commit> [--] [<path>…​] git diff [<オプション>] <コミット> ... <コミット> [ - ] [<パス>…]

This form is to view the changes on the branch containing and up to the second <commit>, starting at a common ancestor of both <commit>. "git diff A...B" is equivalent to "git diff $(git merge-base A B) B". You can omit any one of <commit>, which has the same effect as using HEAD instead.このフォームは、両方の<commit>の共通の先祖から始めて、2番目の<commit>までのブランチの変更を表示します。"git diff A ... B"は "git diff $(gitマージベースAB)B"と同等です。<commit>のいずれかを省略することもできます。これは、代わりにHEADを使用するのと同じ効果があります。

Just in case you are doing something exotic, it should be noted that all of the <commit> in the above description, except in the last two forms that use ".." notations, can be any <tree>.珍しいことをしている場合に備えて、 ".."表記を使用する最後の2つの形式を除いて、上記の説明の<commit>はすべて<tree>になることができます。

For a more complete list of ways to spell <commit>, see "SPECIFYING REVISIONS" section in gitrevisions[7]. However, "diff" is about comparing two endpoints, not ranges, and the range notations ("<commit>..<commit>" and "<commit>...<commit>") do not mean a range as defined in the "SPECIFYING RANGES" section in gitrevisions[7].<commit>をつづる方法のより完全なリストについては、gitrevisions [7]の「リビジョンの指定」の節を参照してください。ただし、 "diff"は範囲ではなく2つの端点を比較することを目的としており、範囲の表記( "<commit> .. <commit>"と "<commit> ... <commit>")はで定義されている範囲を意味しません。gitrevisions [7]の "SPECIFYING RANGES"セクション。

git diff [<options>] <blob> <blob>

This form is to view the differences between the raw contents of two blob objects.このフォームは、2つのBLOBオブジェクトの生の内容の違いを見るためのものです。

OPTIONSオプション

-p
-u
--patch - パッチ

Generate patch (see section on generating patches). This is the default.パッチを生成します(パッチの生成に関する節を見てください)。これがデフォルトです。

-s
--no-patch

Suppress diff output. Useful for commands like git show that show the patch by default, or to cancel the effect of --patch.差分出力を抑制します。git showそのようなコマンドにデフォルトでパッチを表示したり、の効果をキャンセルしたりするのに便利です--patch

-U<n> -U <n>
--unified=<n> --unified = <n>

Generate diffs with <n> lines of context instead of the usual three. Implies -p.通常の3行ではなく<n>行のコンテキストでdiffを生成します。ほのめかし-pます。

--raw - 生

Generate the diff in raw format.生のフォーマットで差分を生成します。

--patch-with-raw

Synonym for -p --raw.の同義語-p --raw

--indent-heuristic

Enable the heuristic that shifts diff hunk boundaries to make patches easier to read. This is the default.パッチを読みやすくするために差分ハンクの境界をシフトするヒューリスティックを有効にします。これがデフォルトです。

--no-indent-heuristic

Disable the indent heuristic.インデントヒューリスティックを無効にします。

--minimal - 最小

Spend extra time to make sure the smallest possible diff is produced.可能な限り最小の差分が生成されるように、余分な時間をかけてください。

--patience - おしゃべり

Generate a diff using the "patience diff" algorithm."patience diff"アルゴリズムを使って差分を生成します。

--histogram - ヒストグラム

Generate a diff using the "histogram diff" algorithm."histogram diff"アルゴリズムを使って差分を生成します。

--anchored=<text> --anchored = <テキスト>

Generate a diff using the "anchored diff" algorithm.「アンカー付き差分」アルゴリズムを使用して差分を生成します。

This option may be specified more than once.このオプションは複数回指定できます。

If a line exists in both the source and destination, exists only once, and starts with this text, this algorithm attempts to prevent it from appearing as a deletion or addition in the output. It uses the "patience diff" algorithm internally.行がソースとデスティネーションの両方に存在し、1回だけ存在し、このテキストで始まる場合、このアルゴリズムはその行が削除または追加として出力に表示されないようにします。内部的に "patience diff"アルゴリズムを使用しています。

--diff-algorithm={patience|minimal|histogram|myers} --diff-algorithm = {patience | minimal | histogram | myers}

Choose a diff algorithm. The variants are as follows:差分アルゴリズムを選択してください。バリアントは以下のとおりです。

default, myers defaultmyers

The basic greedy diff algorithm. Currently, this is the default.基本的な欲張りな差分アルゴリズム。現在、これがデフォルトです。

minimal

Spend extra time to make sure the smallest possible diff is produced.可能な限り最小の差分が生成されるように、余分な時間をかけてください。

patience

Use "patience diff" algorithm when generating patches.パッチを生成するときは "patience diff"アルゴリズムを使用してください。

histogram

This algorithm extends the patience algorithm to "support low-occurrence common elements".このアルゴリズムは、忍耐度アルゴリズムを「発生頻度の低い共通要素をサポートする」ように拡張したものです。

For instance, if you configured the diff.algorithm variable to a non-default value and want to use the default one, then you have to use --diff-algorithm=default option.たとえば、diff.algorithm変数をデフォルト以外の値に設定し、デフォルトの値を使用したい場合は、--diff-algorithm=defaultoption を使用する必要があります。

--stat[=<width>[,<name-width>[,<count>]]] --stat [= <幅> [、<名前 - 幅> [、<数>]]]

Generate a diffstat. By default, as much space as necessary will be used for the filename part, and the rest for the graph part. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by <width>. The width of the filename part can be limited by giving another width <name-width> after a comma. The width of the graph part can be limited by using --stat-graph-width=<width> (affects all commands generating a stat graph) or by setting diff.statGraphWidth=<width> (does not affect git format-patch). By giving a third parameter <count>, you can limit the output to the first <count> lines, followed by ... if there are more.diffstatを生成します。デフォルトでは、必要なだけのスペースがファイル名部分に使用され、残りの部分はグラフ部分に使用されます。最大幅はデフォルトで端末幅に設定され<width>ます。端末に接続されていない場合は80桁になります。ファイル名部分の幅は、<name-width>コンマの後に別の幅を指定することで制限できます。グラフの部分の幅は、使用することによって制限することができる--stat-graph-width=<width>(STATグラフを生成するすべてのコマンドに影響を与える)、または設定してdiff.statGraphWidth=<width>(影響を与えませんgit format-patch)。3番目のパラメータを指定<count>することで、最初の<count>行に出力を制限し、その後にさらに出力がある...場合はそれに続けます。

These parameters can also be set individually with --stat-width=<width>, --stat-name-width=<name-width> and --stat-count=<count>.これらのパラメータは、またして個別に設定することができ--stat-width=<width>--stat-name-width=<name-width>そして--stat-count=<count>

--compact-summary

Output a condensed summary of extended header information such as file creations or deletions ("new" or "gone", optionally "+l" if it’s a symlink) and mode changes ("+x" or "-x" for adding or removing executable bit respectively) in diffstat. The information is put between the filename part and the graph part. Implies --stat.ファイルの作成や削除( "new"または "gone"、オプションで "+ l"、シンボリックリンクの場合はオプションの "+ l"など)やモードの変更(追加または削除の場合は "+ x"や "-x")などの拡張ヘッダー情報の要約を出力します。 diffstatの実行可能ビット)情報はファイル名部分とグラフ部分の間に置かれます。ほのめかし--statます。

--numstat

Similar to --stat, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly. For binary files, outputs two - instead of saying 0 0.に似て--statいますが、追加された行と削除された行の数を10進表記とパス名で表示します。バイナリファイルの場合は、-言う代わりに2 を出力します0 0

--shortstat

Output only the last line of the --stat format containing total number of modified files, as well as number of added and deleted lines.--stat変更されたファイルの総数と、追加された行と削除された行の数を含むフォーマットの最後の行だけを出力します。

--dirstat[=<param1,param2,…​>] --dirstat [= <param1、param2、…>]

Output the distribution of relative amount of changes for each sub-directory. The behavior of --dirstat can be customized by passing it a comma separated list of parameters. The defaults are controlled by the diff.dirstat configuration variable (see git-config[1]). The following parameters are available:各サブディレクトリの相対的な変更量の分布を出力します。の振る舞いは--dirstat、パラメータのコンマ区切りのリストを渡すことでカスタマイズできます。デフォルトはdiff.dirstat設定変数によって制御されます(git-config [1]参照)。以下のパラメータが利用可能です。

changes

Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination. This ignores the amount of pure code movements within a file. In other words, rearranging lines in a file is not counted as much as other changes. This is the default behavior when no parameter is given.転送元から削除された行、または転送先に追加された行をカウントして、dirstat番号を計算します。これはファイル内の純粋なコードの移動量を無視します。つまり、ファイル内の行の並べ替えは、他の変更ほどにはカウントされません。これは、パラメータが指定されていない場合のデフォルトの動作です。

lines

Compute the dirstat numbers by doing the regular line-based diff analysis, and summing the removed/added line counts. (For binary files, count 64-byte chunks instead, since binary files have no natural concept of lines). This is a more expensive --dirstat behavior than the changes behavior, but it does count rearranged lines within a file as much as other changes. The resulting output is consistent with what you get from the other --*stat options.通常の行ベースの差分分析を行い、削除/追加された行数を合計することによって、dirstat数を計算します。(バイナリファイルの場合、バイナリファイルには行の自然な概念がないため、代わりに64バイトのチャンクを数えてください)。これは--dirstat動作よりも高価な動作ですが、changes他の変更と同じくらいファイル内の再配置された行をカウントします。結果の出力は、他の--*statオプションから得られるものと一致しています。

files

Compute the dirstat numbers by counting the number of files changed. Each changed file counts equally in the dirstat analysis. This is the computationally cheapest --dirstat behavior, since it does not have to look at the file contents at all.変更されたファイルの数を数えることによってdirstat番号を計算します。それぞれの変更されたファイルは、嫌悪感分析において等しく数えられます。--dirstatファイルの内容をまったく調べる必要がないため、これは計算上最も安価な動作です。

cumulative

Count changes in a child directory for the parent directory as well. Note that when using cumulative, the sum of the percentages reported may exceed 100%. The default (non-cumulative) behavior can be specified with the noncumulative parameter.親ディレクトリの子ディレクトリの変更もカウントします。使用時cumulativeに、報告されたパーセンテージの合計が100%を超える可能性があることに注意してください。デフォルトの(非累積的な)振る舞いはnoncumulativeパラメータで指定できます。

<limit>

An integer parameter specifies a cut-off percent (3% by default). Directories contributing less than this percentage of the changes are not shown in the output.整数パラメータは、カットオフパーセント(デフォルトでは3%)を指定します。この割合より少ない変更を提供しているディレクトリは、出力には表示されません。

Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories: --dirstat=files,10,cumulative.例:以下は、変更されたファイルの総数の10%未満のディレクトリを無視し、変更されたファイルを数え、親ディレクトリに子ディレクトリの数を累積します--dirstat=files,10,cumulative

--summary - 概要

Output a condensed summary of extended header information such as creations, renames and mode changes.作成、名前変更、モード変更などの拡張ヘッダー情報の要約を出力します。

--patch-with-stat

Synonym for -p --stat.の同義語-p --stat

-z

When --raw, --numstat, --name-only or --name-status has been given, do not munge pathnames and use NULs as output field terminators.とき--raw--numstat--name-onlyまたは--name-status与えられている、パス名をのmungeと出力フィールドターミネータとしてNULsを使用しないでください。

Without this option, pathnames with "unusual" characters are quoted as explained for the configuration variable core.quotePath (see git-config[1]).このオプションを指定しないと、 "変わった"文字を含むパス名は、構成変数で説明されているように引用符で囲まれますcore.quotePathgit-config [1]を参照)。

--name-only

Show only names of changed files.変更されたファイルの名前だけを表示します。

--name-status

Show only names and status of changed files. See the description of the --diff-filter option on what the status letters mean.変更されたファイルの名前とステータスだけを表示します。--diff-filterステータス文字の意味については、オプションの説明を参照してください。

--submodule[=<format>] --submodule [= <フォーマット>]

Specify how differences in submodules are shown. When specifying --submodule=short the short format is used. This format just shows the names of the commits at the beginning and end of the range. When --submodule or --submodule=log is specified, the log format is used. This format lists the commits in the range like git-submodule[1] summary does. When --submodule=diff is specified, the diff format is used. This format shows an inline diff of the changes in the submodule contents between the commit range. Defaults to diff.submodule or the short format if the config option is unset.サブモジュールの違いをどのように表示するかを指定します。指定する場合、短い形式が使用されます。このフォーマットは単に範囲の最初と最後のコミットの名前を表示します。またはが指定されている場合は、ログ形式が使用されます。このフォーマットはgit-submodule [1]のように範囲内のコミットをリストします。を指定した場合は、diff形式が使用されます。このフォーマットは、コミット範囲間のサブモジュールの内容の変化のインライン差分を示しています。configオプションが設定されていない場合は、デフォルトのまたは短い形式になります。--submodule=short--submodule--submodule=log summary--submodule=diffdiff.submodule

--color[=<when>] --color [= <when>]

Show colored diff. --color (i.e. without =<when>) is the same as --color=always. <when> can be one of always, never, or auto. It can be changed by the color.ui and color.diff configuration settings.色付きの差分を表示します。--color(すなわちwithout = <when>はと同じ--color=alwaysです。<とき>のいずれかにすることができalwaysneverまたはautocolor.uicolor.diff設定によって変更できます。

--no-color - 色なし

Turn off colored diff. This can be used to override configuration settings. It is the same as --color=never.色付きの差分をオフにします。これを使用して構成設定を上書きできます。と同じ--color=neverです。

--color-moved[=<mode>] --color-moved [= <モード>]

Moved lines of code are colored differently. It can be changed by the diff.colorMoved configuration setting. The <mode> defaults to no if the option is not given and to zebra if the option with no mode is given. The mode must be one of:移動したコード行は異なる色で表示されます。diff.colorMoved構成設定によって変更できます。オプションが指定されていない場合、<mode>のデフォルトはnoで、モードが指定されていないオプションが指定されている場合はzebraです。モードは次のいずれかでなければなりません。

no いいえ

Moved lines are not highlighted.移動した行は強調表示されません。

default デフォルト

Is a synonym for zebra. This may change to a more sensible mode in the future.の同義語ですzebra。これは将来より賢明なモードに変わるかもしれません。

plain 平野

Any line that is added in one location and was removed in another location will be colored with color.diff.newMoved. Similarly color.diff.oldMoved will be used for removed lines that are added somewhere else in the diff. This mode picks up any moved line, but it is not very useful in a review to determine if a block of code was moved without permutation.ある場所で追加され、別の場所で削除された行は、color.diff.newMovedで色付けされます。同様に、color.diff.oldMovedは差分の他の場所に追加された削除された行に使用されます。このモードは移動された行を拾いますが、コードブロックが置換なしで移動されたかどうかを判断するのにレビューではあまり役に立ちません。

blocks ブロック

Blocks of moved text of at least 20 alphanumeric characters are detected greedily. The detected blocks are painted using either the color.diff.{old,new}Moved color. Adjacent blocks cannot be told apart.少なくとも20文字の英数字の移動されたテキストのブロックは貪欲に検出されます。検出されたブロックは、color.diff。{old、new}のいずれかのを使って描画されます。隣接するブロックを区別することはできません。

zebra シマウマ

Blocks of moved text are detected as in blocks mode. The blocks are painted using either the color.diff.{old,new}Moved color or color.diff.{old,new}MovedAlternative. The change between the two colors indicates that a new block was detected.移動されたテキストのブロックはブロックモードのように検出されます。ブロックは、color.diff。{old、new} Moved colorまたはcolor.diff。{old、new} MovedAlternativeのいずれかを使用して描画されます。2色の変化は、新しいブロックが検出されたことを示します。

dimmed-zebra 薄暗いシマウマ

Similar to zebra, but additional dimming of uninteresting parts of moved code is performed. The bordering lines of two adjacent blocks are considered interesting, the rest is uninteresting. dimmed_zebra is a deprecated synonym.シマウマと似ていますが、動かされたコードの興味のない部分の追加の調光が行われます。2つの隣接するブロックの境界線は興味深いと考えられています、残りは面白くありません。dimmed_zebra非推奨の同義語です。

--no-color-moved - no-color-moved

Turn off move detection. This can be used to override configuration settings. It is the same as --color-moved=no.動き検出をオフにします。これを使用して構成設定を上書きできます。と同じ--color-moved=noです。

--color-moved-ws=<modes> --color-moved-ws = <モード>

This configures how whitespace is ignored when performing the move detection for --color-moved. It can be set by the diff.colorMovedWS configuration setting. These modes can be given as a comma separated list:これは、移動検出を実行するときに空白を無視する方法を設定します--color-moved。それはによって設定することができるdiff.colorMovedWS構成設定。これらのモードは、コンマ区切りのリストとして指定できます。

no いいえ

Do not ignore whitespace when performing move detection.移動検出を実行するときに空白を無視しないでください。

ignore-space-at-eol

Ignore changes in whitespace at EOL.EOLで空白の変更を無視します。

ignore-space-change 無視スペース変更

Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.空白の量の変化を無視します。これは行末の空白を無視し、1つ以上の空白文字の他のすべてのシーケンスを等価と見なします。

ignore-all-space 全スペースを無視

Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.行を比較するときに空白を無視します。片方の行に空白があり、もう一方の行に空白がない場合でも、これは違いを無視します。

allow-indentation-change 許可 - インデント - 変更

Initially ignore any whitespace in the move detection, then group the moved code blocks only into a block if the change in whitespace is the same per line. This is incompatible with the other modes.最初に移動検出で空白を無視し、空白の変化が行ごとに同じである場合は、移動されたコードブロックをブロックにのみグループ化します。これは他のモードと互換性がありません。

--no-color-moved-ws

Do not ignore whitespace when performing move detection. This can be used to override configuration settings. It is the same as --color-moved-ws=no.移動検出を実行するときに空白を無視しないでください。これを使用して構成設定を上書きできます。と同じ--color-moved-ws=noです。

--word-diff[=<mode>] --word-diff [= <モード>]

Show a word diff, using the <mode> to delimit changed words. By default, words are delimited by whitespace; see --word-diff-regex below. The <mode> defaults to plain, and must be one of:変更された単語を区切るために<mode>を使用して単語diffを表示します。デフォルトでは、単語は空白で区切られています。下記を参照してください--word-diff-regex。<mode>のデフォルトはplainで、次のいずれかでなければなりません。

color

Highlight changed words using only colors. Implies --color.色だけを使って変更された単語を強調表示します。ほのめかし--colorます。

plain 平野

Show words as [-removed-] and {+added+}. Makes no attempts to escape the delimiters if they appear in the input, so the output may be ambiguous.[-removed-]ととして単語を表示します{+added+}。区切り文字が入力に含まれている場合は、区切り文字をエスケープしようとしないため、出力があいまいになる可能性があります。

porcelain 磁器

Use a special line-based format intended for script consumption. Added/removed/unchanged runs are printed in the usual unified diff format, starting with a +/-/` ` character at the beginning of the line and extending to the end of the line. Newlines in the input are represented by a tilde ~ on a line of its own.スクリプトを使用するための特別な行ベースの形式を使用してください。追加/削除/変更されていない実行は、行の先頭の+/ -/ ``文字で始まり行の終わりまで続き、通常のunified diff形式で表示されます。入力の改行は、~それ自身の行の上のティルダで表されます。

none 無し

Disable word diff again.単語diffを再び無効にします。

Note that despite the name of the first mode, color is used to highlight the changed parts in all modes if enabled.最初のモードの名前にかかわらず、有効になっている場合は、すべてのモードで変更部分を強調するために色が使用されます。

--word-diff-regex=<regex> --word-diff-regex = <正規表現>

Use <regex> to decide what a word is, instead of considering runs of non-whitespace to be a word. Also implies --word-diff unless it was already enabled.非空白文字の並びを単語と見なすのではなく、<regex>を使用して単語を決定します。--word-diffすでに有効になっていない限り、これも意味します。

Every non-overlapping match of the <regex> is considered a word. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences. You may want to append |[^[:space:]] to your regular expression to make sure that it matches all non-whitespace characters. A match that contains a newline is silently truncated(!) at the newline.<regex>の重複しない一致はすべて単語と見なされます。これらの一致の間にあるものはすべて空白と見なされ、違いを見つける目的で無視されます(!)。|[^[:space:]]正規表現に追加して、空白以外のすべての文字と確実に一致させることができます。改行を含む一致は、改行時に暗黙のうちに切り捨てられます(!)。

For example, --word-diff-regex=. will treat each character as a word and, correspondingly, show differences character by character.たとえば、--word-diff-regex=.各文字を単語として扱い、それに応じて文字ごとに違いを表示します。

The regex can also be set via a diff driver or configuration option, see gitattributes[5] or git-config[1]. Giving it explicitly overrides any diff driver or configuration setting. Diff drivers override configuration settings.正規表現はdiffドライバや設定オプションで設定することもできます。gitattributes[5]またはgit-config [1]を参照してください。明示的に与えると、diffドライバや設定の設定を上書きします。差分ドライバは構成設定を上書きします。

--color-words[=<regex>] --color-words [= <正規表現>]

Equivalent to --word-diff=color plus (if a regex was specified) --word-diff-regex=<regex>.--word-diff=colorplusと同等です(正規表現が指定されている場合)--word-diff-regex=<regex>

--no-renames

Turn off rename detection, even when the configuration file gives the default to do so.設定ファイルがデフォルトを指定している場合でも、名前の変更の検出を無効にします。

--check - チェック

Warn if changes introduce conflict markers or whitespace errors. What are considered whitespace errors is controlled by core.whitespace configuration. By default, trailing whitespaces (including lines that consist solely of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors. Exits with non-zero status if problems are found. Not compatible with --exit-code.変更によって競合マーカーまたは空白エラーが発生するかどうかを警告します。空白エラーと見なされるものはcore.whitespace構成によって制御されます。デフォルトでは、末尾の空白(空白のみで構成される行を含む)およびその行の最初のインデントの内側にタブ文字が直後に続く空白文字は空白エラーと見なされます。問題が見つかった場合は、ゼロ以外のステータスで終了します。--exit-codeと互換性がありません。

--ws-error-highlight=<kind> --ws-error-highlight = <種類>

Highlight whitespace errors in the context, old or new lines of the diff. Multiple values are separated by comma, none resets previous values, default reset the list to new and all is a shorthand for old,new,context. When this option is not given, and the configuration variable diff.wsErrorHighlight is not set, only whitespace errors in new lines are highlighted. The whitespace errors are colored with color.diff.whitespace.差分のcontextoldまたは行内の空白エラーを強調表示しますnew。複数の値は、コンマによって分離されるnone前の値をリセットし、defaultにリストをリセットnewallの省略形ですold,new,context。このオプションが指定されておらず、設定変数diff.wsErrorHighlightが設定されていない場合、行内の空白エラーのみnewが強調表示されます。空白エラーは色付きcolor.diff.whitespaceです。

--full-index

Instead of the first handful of characters, show the full pre- and post-image blob object names on the "index" line when generating patch format output.最初の一握りの文字の代わりに、パッチフォーマットの出力を生成するときに、 "index"行に完全なプリイメージとポストイメージのBLOBオブジェクト名を表示します。

--binary - バイナリ

In addition to --full-index, output a binary diff that can be applied with git-apply.に加えて--full-index、適用できるバイナリ差分を出力しgit-applyます。

--abbrev[=<n>] --abbrev [= <n>]

Instead of showing the full 40-byte hexadecimal object name in diff-raw format output and diff-tree header lines, show only a partial prefix. This is independent of the --full-index option above, which controls the diff-patch output format. Non default number of digits can be specified with --abbrev=<n>.diff-raw形式の出力とdiff-treeヘッダー行に完全な40バイトの16進数のオブジェクト名を表示する代わりに、部分的なプレフィックスのみを表示します。これは--full-index、diff-patchの出力フォーマットを制御する上記のオプションとは無関係です。デフォルト以外の桁数をで指定できます--abbrev=<n>

-B[<n>][/<m>] -B [<n>] [/ <m>]
--break-rewrites[=[<n>][/<m>]] --break-rewritees [= [<n>] [/ <m>]]

Break complete rewrite changes into pairs of delete and create. This serves two purposes:完全な書き換えの変更を削除と作成のペアに分割します。これには2つの目的があります。

It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number m controls this aspect of the -B option (defaults to 60%). -B/70% specifies that less than 30% of the original should remain in the result for Git to consider it a total rewrite (i.e. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines).それは、文脈としてテキスト的に一致することが起こる非常に少数の行と混合された一連の削除と挿入としてではなく、ファイルの完全な書き換えに相当する変更に影響する方法に影響します。新しいものすべてを1回挿入mすると、その数によって-Bオプションのこの側面が制御されます(デフォルトは60%)。-B/70%Gitが完全な書き換えと見なすには、元の30%未満を結果に残すように指定します(そうでなければ、結果として得られるパッチは、一連の削除と挿入がコンテキスト行と混在したものになります)。

When used with -M, a totally-rewritten file is also considered as the source of a rename (usually -M only considers a file that disappeared as the source of a rename), and the number n controls this aspect of the -B option (defaults to 50%). -B20% specifies that a change with addition and deletion compared to 20% or more of the file’s size are eligible for being picked up as a possible source of a rename to another file.-Mと一緒に使用すると、完全に書き換えられたファイルも名前変更のソースと見なされ(通常、-Mは、名前変更のソースとして表示されなくなったファイルのみを考慮します)、- nBオプションのこの側面を制御します。デフォルトは50%です。-B20%ファイルのサイズの20%以上と比較した追加および削除による変更が、別のファイルへの名前変更の可能性のあるソースとして選択されるのに適格であることを指定します。

-M[<n>] -M [<n>]
--find-renames[=<n>] --find-renames [= <n>]

Detect renames. If n is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example, -M90% means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed. Without a % sign, the number is to be read as a fraction, with a decimal point before it. I.e., -M5 becomes 0.5, and is thus the same as -M50%. Similarly, -M05 is the same as -M5%. To limit detection to exact renames, use -M100%. The default similarity index is 50%.名前変更を検出します。n指定されている場合、それは類似性インデックス(つまり、ファイルのサイズと比較した追加/削除の量)に関するしきい値です。たとえば-M90%、ファイルの90%以上が変更されていない場合、Gitは削除/追加のペアを名前の変更と見なす必要があります。%符号なしの場合、数値は小数点の前に小数部として読み取られます。すなわち、-M50.5 になるので、と同じ-M50%です。同様に、-M05と同じ-M5%です。検出を正確な名前変更に限定するには、を使用します-M100%。デフォルトの類似度は50%です。

-C[<n>] -C [<n>]
--find-copies[=<n>] --find-copies [= <n>]

Detect copies as well as renames. See also --find-copies-harder. If n is specified, it has the same meaning as for -M<n>.コピーと名前の変更を検出します。もご覧ください--find-copies-hardernを指定した場合は、と同じ意味になり-M<n>ます。

--find-copies-harder

For performance reasons, by default, -C option finds copies only if the original file of the copy was modified in the same changeset. This flag makes the command inspect unmodified files as candidates for the source of copy. This is a very expensive operation for large projects, so use it with caution. Giving more than one -C option has the same effect.パフォーマンス上の理由から、デフォルトで-Cは、コピーの元のファイルが同じチェンジセット内で変更されている場合にのみコピーが検索されます。このフラグは、コピー元の候補として未修正のファイルを検査します。これは大規模プロジェクトでは非常に高価な操作なので、慎重に使用してください。複数の-Cオプションを指定しても同じ効果があります。

-D
--irreversible-delete

Omit the preimage for deletes, i.e. print only the header but not the diff between the preimage and /dev/null. The resulting patch is not meant to be applied with patch or git apply; this is solely for people who want to just concentrate on reviewing the text after the change. In addition, the output obviously lacks enough information to apply such a patch in reverse, even manually, hence the name of the option.削除のためにpreimageを省略してください、すなわち、preimageとの間の差分ではなくヘッダーだけを印刷してください/dev/null。得られたパッチが適用されることを意図されていないpatch、またはgit apply、これは、変更後のテキストを見直すことに専念したい人のためだけのものです。さらに、そのようなパッチを手動でも逆に適用するのに十分な情報が出力に欠けているため、オプションの名前です。

When used together with -B, omit also the preimage in the deletion part of a delete/create pair.一緒に使用する場合-Bは、削除/作成ペアの削除部分のプレイメージも省略します。

-l<num> -l <番号>

The -M and -C options require O(n^2) processing time where n is the number of potential rename/copy targets. This option prevents rename/copy detection from running if the number of rename/copy targets exceeds the specified number.-Mそして-Cオプションは、nは電位リネーム/コピー標的の数はO(N ^ 2)の処理時間を必要とします。このオプションは、名前変更/コピーターゲットの数が指定された数を超えた場合に名前変更/コピー検出が実行されないようにします。

--diff-filter=[(A|C|D|M|R|T|U|X|B)…​[*]] --diff-filter = [(A | C | D | M | R | T | U | X | B)…[*]]

Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular file, symlink, submodule, …​) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B). Any combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.追加(A)、コピー(C)、削除(D)、変更(M)、名前変更(R)、タイプ(通常ファイル、シンボリックリンク、サブモジュールなど)が変更されている(T)、Unmerged(U)であるファイルのみを選択します。不明(X)、またはペアリングが壊れている(B)。フィルタ文字の任意の組み合わせ(なしを含む)を使用できます。場合*(全か無か)の組み合わせに添加する比較して他の基準に一致するすべてのファイルが存在する場合、すべてのパスが選択されます。他の基準に一致するファイルがない場合は、何も選択されません。

Also, these upper-case letters can be downcased to exclude. E.g. --diff-filter=ad excludes added and deleted paths.また、これらの大文字は除外するために小文字にすることができます。例えば--diff-filter=ad追加されたパスや削除されたパスを除外します。

Note that not all diffs can feature all types. For instance, diffs from the index to the working tree can never have Added entries (because the set of paths included in the diff is limited by what is in the index). Similarly, copied and renamed entries cannot appear if detection for those types is disabled.すべての差分がすべての型を扱えるわけではないことに注意してください。たとえば、インデックスから作業ツリーへの差分は、追加エントリを持つことはできません(差分に含まれるパスのセットは、インデックスに含まれるものによって制限されるため)。同様に、これらのタイプの検出が無効になっていると、コピーして名前を変更したエントリーは表示されません。

-S<string> -S <文字列>

Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter’s use.ファイル内の指定された文字列の出現回数(すなわち追加/削除)を変更する違いを探します。スクリプト作成者の使用を目的としています。

It is useful when you’re looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into -S, and keep going until you get the very first version of the block.コードの正確なブロック(構造体など)を探していて、そのブロックが最初に登場してからの履歴を知りたい場合に便利です。プレイメージの中の興味深いブロックを繰り返し使用することで、-Sそして、あなたがブロックの一番最初のバージョンを手に入れるまで続けてください。

Binary files are searched as well.バイナリファイルも検索されます。

-G<regex> -G <正規表現>

Look for differences whose patch text contains added/removed lines that match <regex>.パッチテキストに<regex>と一致する追加/削除された行が含まれている違いを探します。

To illustrate the difference between -S<regex> --pickaxe-regex and -G<regex>, consider a commit with the following diff in the same file:-S<regex> --pickaxe-regexとの違いを説明するため-G<regex>に、同じファイル内で次のdiffを使用したコミットを考えます。

+    return !regexec(regexp, two->ptr, 1, &regmatch, 0);
...
-    hit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);

While git log -G"regexec\(regexp" will show this commit, git log -S"regexec\(regexp" --pickaxe-regex will not (because the number of occurrences of that string did not change).一方ではgit log -G"regexec\(regexp"、このコミット表示されますgit log -S"regexec\(regexp" --pickaxe-regex(その文字列の出現回数が変更されていないので)ではないでしょう。

Unless --text is supplied patches of binary files without a textconv filter will be ignored.--texttextconvフィルタのないバイナリファイルのパッチが提供されていない限り無視されます。

See the pickaxe entry in gitdiffcore[7] for more information.詳細についてはgitdiffcore [7]pickaxeエントリを参照してください。

--find-object=<object-id> --find-object = <オブジェクトID>

Look for differences that change the number of occurrences of the specified object. Similar to -S, just the argument is different in that it doesn’t search for a specific string but for a specific object id.指定されたオブジェクトの出現回数を変更する違いを探します。と同様に-S、引数は、特定の文字列ではなく特定のオブジェクトIDを検索するという点で異なります。

The object can be a blob or a submodule commit. It implies the -t option in git-log to also find trees.オブジェクトはBLOBまたはサブモジュールのコミットです。それは木も見つけるための-t選択肢を意味しますgit-log

--pickaxe-all

When -S or -G finds a change, show all the changes in that changeset, not just the files that contain the change in <string>.とき-Sまたは-G変更を見つけ、そのチェンジ内のすべての変更、<文字列>の変化が含まれていないファイルだけを表示します。

--pickaxe-regex

Treat the <string> given to -S as an extended POSIX regular expression to match.に与えられた<string>を-S拡張POSIX正規表現として扱います。

-O<orderfile> -O <orderfile>

Control the order in which files appear in the output. This overrides the diff.orderFile configuration variable (see git-config[1]). To cancel diff.orderFile, use -O/dev/null.出力に表示されるファイルの順序を制御します。これはdiff.orderFile設定変数を上書きします(git-config [1]を参照)。キャンセルするにdiff.orderFileはを使用してください-O/dev/null

The output order is determined by the order of glob patterns in <orderfile>. All files with pathnames that match the first pattern are output first, all files with pathnames that match the second pattern (but not the first) are output next, and so on. All files with pathnames that do not match any pattern are output last, as if there was an implicit match-all pattern at the end of the file. If multiple pathnames have the same rank (they match the same pattern but no earlier patterns), their output order relative to each other is the normal order.出力順序は、<orderfile>内のglobパターンの順序によって決まります。最初のパターンと一致するパス名を持つすべてのファイルが最初に出力され、2番目のパターンと一致するが最初のパターンと一致しないパス名を持つすべてのファイルが次に出力されます。どのパターンとも一致しないパス名を持つすべてのファイルは、あたかもファイルの終わりに暗黙の全部突き合わせパターンがあったかのように、最後に出力されます。複数のパス名が同じランクを持つ場合(それらは同じパターンに一致しますが、以前のパターンには一致しない場合)、互いに対する相対的な出力順序は通常の順序です。

<orderfile> is parsed as follows:<orderfile>は次のように解析されます。

  • Blank lines are ignored, so they can be used as separators for readability.空白行は無視されるため、読みやすくするために区切り文字として使用できます。

  • Lines starting with a hash ("#") are ignored, so they can be used for comments. Add a backslash ("\") to the beginning of the pattern if it starts with a hash.ハッシュ( " #")で始まる行は無視されるため、コメントに使用できます。\ハッシュで始まる場合は、パターンの先頭に円記号( " ")を追加します。

  • Each other line contains a single pattern.他の各行には単一のパターンが含まれています。

Patterns have the same syntax and semantics as patterns used for fnmatch(3) without the FNM_PATHNAME flag, except a pathname also matches a pattern if removing any number of the final pathname components matches the pattern. For example, the pattern "foo*bar" matches "fooasdfbar" and "foo/bar/baz/asdf" but not "foobarx".パターンは、FNM_PATHNAMEフラグなしでfnmatch(3)に使用されるパターンと同じ構文および意味論を持ちます。ただし、最終パス名の構成要素をいくつでも削除した場合、パス名もパターンと一致する点が異なります。たとえば、パターン " foo*bar"は " fooasdfbar"と " foo/bar/baz/asdf"には一致しますが " "には一致しませんfoobarx

-R

Swap two inputs; that is, show differences from index or on-disk file to tree contents.2つの入力を入れ替えます。つまり、インデックスまたはディスク上のファイルとツリーの内容との違いを示します。

--relative[=<path>] --relative [= <パス>]

When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option. When you are not in a subdirectory (e.g. in a bare repository), you can name which subdirectory to make the output relative to by giving a <path> as an argument.プロジェクトのサブディレクトリから実行すると、ディレクトリ外の変更を除外し、このオプションを使用してディレクトリに対する相対パス名を表示するように指示できます。サブディレクトリにいないとき(例えば、ベアリポジトリ)、引数として<path>を与えることによって、どのサブディレクトリに相対的な出力をするかを指定できます。

-a
--text - テキスト

Treat all files as text.すべてのファイルをテキストとして扱います。

--ignore-cr-at-eol

Ignore carriage-return at the end of line when doing a comparison.比較をするとき、行末での復帰を無視します。

--ignore-space-at-eol

Ignore changes in whitespace at EOL.EOLで空白の変更を無視します。

-b
--ignore-space-change

Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.空白の量の変化を無視します。これは行末の空白を無視し、1つ以上の空白文字の他のすべてのシーケンスを等価と見なします。

-w
--ignore-all-space

Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.行を比較するときに空白を無視します。片方の行に空白があり、もう一方の行に空白がない場合でも、これは違いを無視します。

--ignore-blank-lines

Ignore changes whose lines are all blank.すべての行が空白になっている変更を無視します。

--inter-hunk-context=<lines> --inter-hunk-context = <lines>

Show the context between diff hunks, up to the specified number of lines, thereby fusing hunks that are close to each other. Defaults to diff.interHunkContext or 0 if the config option is unset.指定した行数までの差分ハンク間のコンテキストを表示し、それによって互いに近いハンクを融合します。diff.interHunkContextconfigオプションが設定されていない場合、デフォルトは0または0です。

-W
--function-context - 機能コンテキスト

Show whole surrounding functions of changes.変更の周囲の機能全体を表示します。

--exit-code

Make the program exit with codes similar to diff(1). That is, it exits with 1 if there were differences and 0 means no differences.diff(1)に似たコードでプログラムを終了させます。つまり、違いがある場合は1で、違いがない場合は0で終了します。

--quiet - 静か

Disable all output of the program. Implies --exit-code.プログラムのすべての出力を無効にします。ほのめかし--exit-codeます。

--ext-diff

Allow an external diff helper to be executed. If you set an external diff driver with gitattributes[5], you need to use this option with git-log[1] and friends.外部のdiffヘルパーを実行できるようにします。gitattributes [5]で外部のdiffドライバを設定した場合は、git-log [1]とその仲間と共にこのオプションを使う必要があります。

--no-ext-diff

Disallow external diff drivers.外部のdiffドライバを許可しません。

--textconv
--no-textconv

Allow (or disallow) external text conversion filters to be run when comparing binary files. See gitattributes[5] for details. Because textconv filters are typically a one-way conversion, the resulting diff is suitable for human consumption, but cannot be applied. For this reason, textconv filters are enabled by default only for git-diff[1] and git-log[1], but not for git-format-patch[1] or diff plumbing commands.バイナリファイルを比較するときに外部テキスト変換フィルタを実行することを許可(または禁止)します。詳細はgitattributes [5]を見てください。textconvフィルタは通常一方向の変換であるため、結果の差分は人間の消費には適していますが、適用することはできません。このため、textconvフィルタは、git-diff [1]およびgit-log [1]に対してのみデフォルトで有効になりますが、git-format-patch [1]またはdiff plumbingコマンドには無効になります。

--ignore-submodules[=<when>] --ignore-submodules [= <when>]

Ignore changes to submodules in the diff generation. <when> can be either "none", "untracked", "dirty" or "all", which is the default. Using "none" will consider the submodule modified when it either contains untracked or modified files or its HEAD differs from the commit recorded in the superproject and can be used to override any settings of the ignore option in git-config[1] or gitmodules[5]. When "untracked" is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content). Using "dirty" ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior until 1.7.0). Using "all" hides all changes to submodules.差分生成でサブモジュールへの変更を無視します。<when>は、 "none"、 "untracked"、 "dirty"、または "all"のいずれかです。これがデフォルトです。noneを使用すると、追跡されていないファイルまたは変更されたファイルが含まれている場合、またはそのHEADがスーパープロジェクトに記録されたコミットと異なる場合に変更されたサブモジュールが考慮されます。git -config [1]またはgitmodules [ 1]ignoreオプションの設定を上書きするために使用できます。 5]。「追跡されていない」が使用されている場合、サブモジュールは追跡されていないコンテンツのみを含む場合はダーティとは見なされません(ただし、変更されたコンテンツについてはスキャンされます)。"dirty"を使用しても、サブモジュールの作業ツリーに対するすべての変更は無視されます。スーパープロジェクトに保存されているコミットへの変更のみが表示されます(これは1.7.0までの動作でした)。"all"を使用すると、サブモジュールに対するすべての変更が隠されます。

--src-prefix=<prefix> --src-prefix = <prefix>

Show the given source prefix instead of "a/"."a /"の代わりに与えられたソースプレフィックスを表示します。

--dst-prefix=<prefix> --dst-prefix = <prefix>

Show the given destination prefix instead of "b/"."b /"の代わりに与えられた宛先プレフィックスを表示します。

--no-prefix

Do not show any source or destination prefix.送信元または宛先のプレフィックスを表示しません。

--line-prefix=<prefix> --line-prefix = <prefix>

Prepend an additional prefix to every line of output.出力の各行に追加の接頭辞を付けます。

--ita-invisible-in-index

By default entries added by "git add -N" appear as an existing empty file in "git diff" and a new file in "git diff --cached". This option makes the entry appear as a new file in "git diff" and non-existent in "git diff --cached". This option could be reverted with --ita-visible-in-index. Both options are experimental and could be removed in future.デフォルトでは、 "git add -N"で追加されたエントリは、 "git diff"には既存の空のファイルとして、 "git diff --cached"には新しいファイルとして表示されます。このオプションはエントリを "git diff"では新しいファイルとして、 "git diff --cached"では存在しないように見せます。このオプションは元に戻すことができます--ita-visible-in-index。どちらのオプションも実験的であり、将来削除される可能性があります。

For more detailed explanation on these common options, see also gitdiffcore[7].これらの共通オプションに関するより詳細な説明については、gitdiffcore [7]も参照してください。

-1 --base -1 - ベース
-2 --ours -2 - 時間
-3 --theirs -3 - 彼ら

Compare the working tree with the "base" version (stage #1), "our branch" (stage #2) or "their branch" (stage #3). The index contains these stages only for unmerged entries i.e. while resolving conflicts. See git-read-tree[1] section "3-Way Merge" for detailed information.作業ツリーを "base"バージョン(ステージ#1)、 "our branch"(ステージ#2)、または "their branch"(ステージ#3)と比較します。インデックスには、マージされていないエントリ、つまり競合を解決するためのエントリのみが含まれます。詳細についてはgit-read-tree [1]の「3-Way Merge」を参照してください。

-0

Omit diff output for unmerged entries and just show "Unmerged". Can be used only when comparing the working tree with the index.マージされていないエントリについてはdiffの出力を省略し、単に "Unmerged"と表示します。作業ツリーとインデックスを比較する場合にのみ使用できます。

<path>…​ <パス>…

The <paths> parameters, when given, are used to limit the diff to the named paths (you can give directory names and get diff for all files under them).<paths>パラメータが与えられたとき、それはdiffを名前付きパスに制限するために使われます(ディレクトリ名を与えて、その下のすべてのファイルに対してdiffを得ることができます)。

Raw output format生の出力フォーマット

The raw output format from "git-diff-index", "git-diff-tree", "git-diff-files" and "git diff --raw" are very similar."git-diff-index"、 "git-diff-tree"、 "git-diff-files"、 "git diff --raw"の生の出力フォーマットは非常に似ています。

These commands all compare two sets of things; what is compared differs:これらのコマンドはすべて2つのことを比較します。比較対象は異なります。

git-diff-index <tree-ish> git-diff-index <ツリー>

compares the <tree-ish> and the files on the filesystem.<tree-ish>とファイルシステム上のファイルを比較します。

git-diff-index --cached <tree-ish> git-diff-index --cached <ツリー>

compares the <tree-ish> and the index.<tree-ish>とインデックスを比較します。

git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…​] git-diff-tree [-r] <ツリー> -1> <ツリー-2> [<パターン>…]

compares the trees named by the two arguments.2つの引数によって指定されたツリーを比較します。

git-diff-files [<pattern>…​] git-diff-files [<パターン>…]

compares the index and the files on the filesystem.インデックスとファイルシステム上のファイルを比較します。

The "git-diff-tree" command begins its output by printing the hash of what is being compared. After that, all the commands print one output line per changed file."git-diff-tree"コマンドは、比較対象のハッシュを表示することによって出力を開始します。その後、すべてのコマンドは変更されたファイルごとに1行の出力を表示します。

An output line is formatted this way:出力行はこのようにフォーマットされています。

in-place edit  :100644 100644 bcd1234 0123456 M file0
copy-edit      :100644 100644 abcd123 1234567 C68 file1 file2
rename-edit    :100644 100644 abcd123 1234567 R86 file1 file3
create         :000000 100644 0000000 1234567 A file4
delete         :100644 000000 1234567 0000000 D file5
unmerged       :000000 000000 0000000 0000000 U file6

That is, from the left to the right:つまり、左から右へ:

  1. a colon.コロン

  2. mode for "src"; 000000 if creation or unmerged."src"のモード。作成または未マージの場合は000000。

  3. a space.スペース。

  4. mode for "dst"; 000000 if deletion or unmerged."dst"のモード。削除またはマージされていない場合は000000

  5. a space.スペース。

  6. sha1 for "src"; 0{40} if creation or unmerged.sha1は "src"です。作成または未マージの場合は0 {40}。

  7. a space.スペース。

  8. sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".sha1は "dst"です。0作成、マージされていない、または「ワークツリーを見て」の場合0 {40}。

  9. a space.スペース。

  10. status, followed by optional "score" number.ステータス、オプションの「スコア」番号が続きます。

  11. a tab or a NUL when -z option is used.-zオプションが使用されている場合はタブまたはNUL 。

  12. path for "src""src"へのパス

  13. a tab or a NUL when -z option is used; only exists for C or R.-zオプションが使用されている場合はタブまたはNUL 。CまたはRにのみ存在します。

  14. path for "dst"; only exists for C or R."dst"のパス。CまたはRにのみ存在します。

  15. an LF or a NUL when -z option is used, to terminate the record.-zオプションを使用する場合はLFまたはNUL 。レコードを終了します。

Possible status letters are:可能なステータス文字は次のとおりです。

  • A: addition of a fileA:ファイルの追加

  • C: copy of a file into a new oneC:ファイルを新しいファイルにコピーする

  • D: deletion of a fileD:ファイルの削除

  • M: modification of the contents or mode of a fileM:ファイルの内容またはモードの変更

  • R: renaming of a fileR:ファイル名の変更

  • T: change in the type of the fileT:ファイルの種類を変更する

  • U: file is unmerged (you must complete the merge before it can be committed)U:ファイルはマージされていません(コミットする前にマージを完了する必要があります)

  • X: "unknown" change type (most probably a bug, please report it)X: "未知の"変更タイプ(たぶんバグです。報告してください)

Status letters C and R are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy). Status letter M may be followed by a score (denoting the percentage of dissimilarity) for file rewrites.ステータス文字CとRの後には常にスコア(移動またはコピーのソースとターゲットの間の類似性のパーセンテージを示す)が続きます。ステータスレターMの後には、ファイルの書き換えに対するスコア(非類似の割合を示す)が続く場合があります。

<sha1> is shown as all 0’s if a file is new on the filesystem and it is out of sync with the index.ファイルがファイルシステム上で新しく、それがインデックスと同期していない場合、<sha1>はすべて0として表示されます。

Example:例:

:100644 100644 5be4a4a 0000000 M file.c

Without the -z option, pathnames with "unusual" characters are quoted as explained for the configuration variable core.quotePath (see git-config[1]). Using -z the filename is output verbatim and the line is terminated by a NUL byte.この-zオプションがなければ、"変わった"文字を含むパス名は設定変数で説明されているように引用符で囲まれますcore.quotePathgit-config [1]を参照)。-zファイル名を使用すると逐語的に出力され、行はNULバイトで終了します。

diff format for mergesマージ用のdiff形式

"git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or --cc option to generate diff output also for merge commits. The output differs from the format described above in the following way:"git-diff-tree"、 "git-diff-files"、および "git-diff --raw"は、マージコミットに対してもdiff出力を生成する-cかどうかを--cc選択できます。出力は、次の点で上記の形式と異なります。

  1. there is a colon for each parent各親にコロンがあります

  2. there are more "src" modes and "src" sha1より多くの "src"モードと "src" sha1があります

  3. status is concatenated status characters for each parentstatusは各親のステータス文字を連結したものです

  4. no optional "score" numberオプションの「スコア」番号はありません

  5. single path, only for "dst"単一パス、 "dst"専用

Example:例:

::100644 100644 100644 fabadb8 cc95eb0 4866510 MM	describe.c

Note that combined diff lists only files which were modified from all parents.その注意を組み合わせデフすべての親から変更されたリストファイルのみを。

Generating patches with -p-pによるパッチの生成

When "git-diff-index", "git-diff-tree", or "git-diff-files" are run with a -p option, "git diff" without the --raw option, or "git log" with the "-p" option, they do not produce the output described above; instead they produce a patch file. You can customize the creation of such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables."git-diff-index"、 "git-diff-tree"、または "git-diff-files"を-pオプション付きで実行した場合、 "git diff" --rawオプションなし、または "git log"に "-p"を指定した場合オプションとして、それらは上記の出力を生成しません。代わりにパッチファイルを作成します。環境変数を使用してGIT_EXTERNAL_DIFF、そのようなパッチの作成をカスタマイズできGIT_DIFF_OPTSます。

What the -p option produces is slightly different from the traditional diff format:-pオプションが生成するものは、従来のdiff形式とは少し異なります。

  1. It is preceded with a "git diff" header that looks like this:このように見える "git diff"ヘッダが前にあります。

    diff --git a/file1 b/file2

    The a/ and b/ filenames are the same unless rename/copy is involved. Especially, even for a creation or a deletion, /dev/null is not used in place of the a/ or b/ filenames.a/およびb/名前変更/コピーが関与しなければ、ファイル名は同じです。特に、でも作成や削除のために、/dev/nullされていないの代わりに使用するa/か、b/ファイル名。

    When rename/copy is involved, file1 and file2 show the name of the source file of the rename/copy and the name of the file that rename/copy produces, respectively.名前変更/コピーが関与した場合file1file2名前の変更/コピーのソースファイルの名前と/コピーはそれぞれ、生産名前を変更するファイルの名前を表示します。

  2. It is followed by one or more extended header lines:その後に1つ以上の拡張ヘッダー行が続きます。

    old mode <mode>
    new mode <mode>
    deleted file mode <mode>
    new file mode <mode>
    copy from <path>
    copy to <path>
    rename from <path>
    rename to <path>
    similarity index <number>
    dissimilarity index <number>
    index <hash>..<hash> <mode>

    File modes are printed as 6-digit octal numbers including the file type and file permission bits.ファイルモードは、ファイルタイプとファイル許可ビットを含む6桁の8進数として表示されます。

    Path names in extended headers do not include the a/ and b/ prefixes.拡張ヘッダー内のパス名には、a/およびb/プレフィックスは含まれません。

    The similarity index is the percentage of unchanged lines, and the dissimilarity index is the percentage of changed lines. It is a rounded down integer, followed by a percent sign. The similarity index value of 100% is thus reserved for two equal files, while 100% dissimilarity means that no line from the old file made it into the new one.類似度指数は変更されていない行の割合であり、非類似度指数は変更された行の割合です。切り捨てられた整数の後にパーセント記号が続きます。したがって、100%の類似性インデックス値は、2つの等しいファイル用に予約されていますが、100%の非類似性は、古いファイルから新しいファイルに変更された行がないことを意味します。

    The index line includes the SHA-1 checksum before and after the change. The <mode> is included if the file mode does not change; otherwise, separate lines indicate the old and the new mode.インデックス行には、変更前後のSHA-1チェックサムが含まれています。ファイルモードが変更されない場合は、<mode>が含まれます。それ以外の場合、別々の行は新旧のモードを示します。

  3. Pathnames with "unusual" characters are quoted as explained for the configuration variable core.quotePath (see git-config[1])."変わった"文字を含むパス名は、構成変数で説明されているように引用符で囲まれていますcore.quotePathgit-config [1]を参照)。

  4. All the file1 files in the output refer to files before the commit, and all the file2 files refer to files after the commit. It is incorrect to apply each change to each file sequentially. For example, this patch will swap a and b:file1出力内のすべてのファイルはコミット前のfile2ファイルを参照し、すべてのファイルはコミット後のファイルを参照します。各ファイルに各変更を順番に適用するのは正しくありません。たとえば、このパッチはaとbを入れ替えます。

    diff --git a/a b/b
    rename from a
    rename to b
    diff --git a/b b/a
    rename from b
    rename to a

combined diff format複合差分フォーマット

Any diff-generating command can take the -c or --cc option to produce a combined diff when showing a merge. This is the default format when showing merges with git-diff[1] or git-show[1]. Note also that you can give the -m option to any of these commands to force generation of diffs with individual parents of a merge.どのdiff-generationコマンドでも、マージを表示するときに-cor --ccオプションを使用して結合差分を生成できます。これはgit-diff [1]またはgit-show [1]でマージを表示するときのデフォルトのフォーマットです。また-m、マージの個々の親との差分の生成を強制するために、これらのコマンドのいずれかにオプションを与えることができます。

A combined diff format looks like this:組み合わせ差分形式は、次のようになります。

diff --combined describe.c
index fabadb8,cc95eb0..4866510
--- a/describe.c
+++ b/describe.c
@@@ -98,20 -98,12 +98,20 @@@
	return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
  }
- static void describe(char *arg)
 -static void describe(struct commit *cmit, int last_one)
++static void describe(char *arg, int last_one)
  {
 +	unsigned char sha1[20];
 +	struct commit *cmit;
	struct commit_list *list;
	static int initialized = 0;
	struct commit_name *n;
 +	if (get_sha1(arg, sha1) < 0)
 +		usage(describe_usage);
 +	cmit = lookup_commit_reference(sha1);
 +	if (!cmit)
 +		usage(describe_usage);
 +
	if (!initialized) {
		initialized = 1;
		for_each_ref(get_name);
  1. It is preceded with a "git diff" header, that looks like this (when -c option is used):これは "git diff"ヘッダが前に-c付きます。これは次のようになります(オプションが使用されている場合)。

    diff --combined file

    or like this (when --cc option is used):または(--ccオプションが使用されている場合)このように:

    diff --cc file
  2. It is followed by one or more extended header lines (this example shows a merge with two parents):その後に1つ以上の拡張ヘッダー行が続きます(この例は、2つの親とのマージを示しています)。

    index <hash>,<hash>..<hash>
    mode <mode>,<mode>..<mode>
    new file mode <mode>
    deleted file mode <mode>,<mode>

    The mode <mode>,<mode>..<mode> line appears only if at least one of the <mode> is different from the rest. Extended headers with information about detected contents movement (renames and copying detection) are designed to work with diff of two <tree-ish> and are not used by combined diff format.このmode <mode>,<mode>..<mode>行は、少なくとも1つの<mode>が他のものと異なる場合にのみ表示されます。検出されたコンテンツの移動に関する情報(名前の変更とコピーの検出)を含む拡張ヘッダーは、2つの<tree-ish>のdiffで機能するように設計されており、複合diff形式では使用されません。

  3. It is followed by two-line from-file/to-file headerその後に2行のファイルから/ファイルへのヘッダーが続きます。

    --- a/file
    +++ b/file

    Similar to two-line header for traditional unified diff format, /dev/null is used to signal created or deleted files.伝統的なunified diff形式の2行のヘッダと同様に、/dev/null作成または削除されたファイルを知らせるために使用されます。

  4. Chunk header format is modified to prevent people from accidentally feeding it to patch -p1. Combined diff format was created for review of merge commit changes, and was not meant for apply. The change is similar to the change in the extended index header:チャンクヘッダーのフォーマットは、人々が誤ってそれにフィードするのを防ぐために修正されていpatch -p1ます。結合差分フォーマットは、マージコミットの変更を確認するために作成されたものであり、適用するためのものではありません。この変更は、拡張インデックスヘッダの変更と似ています。

    @@@ <from-file-range> <from-file-range> <to-file-range> @@@

    There are (number of parents + 1) @ characters in the chunk header for combined diff format.@複合差分フォーマットのチャンクヘッダには(親の数+ 1)文字があります。

Unlike the traditional unified diff format, which shows two files A and B with a single column that has - (minus — appears in A but removed in B), + (plus — missing in A but added to B), or " " (space — unchanged) prefix, this format compares two or more files file1, file2,…​ with one file X, and shows how X differs from each of fileN. One column for each of fileN is prepended to the output line to note how X’s line is different from it.(マイナス - Aでは表示されているがBでは削除されている)または(スペース - 変更されていない)を持つ単一の列を持つ2つのファイルAおよびBを示す従来のunified diff形式とは異なります。接頭辞、この形式は複数のファイルfile1、file2、…を1つのファイルXと比較し、XがfileNのそれぞれとどう違うかを示します。Xの行がそれとどのように異なるかを確認するために、fileNのそれぞれに対して1列が出力行の前に追加されます。-+" "

A - character in the column N means that the line appears in fileN but it does not appear in the result. A + character in the column N means that the line appears in the result, and fileN does not have that line (in other words, the line was added, from the point of view of that parent).-列Nの文字は行がfileNに表示されますが、それは結果に表示されないことを意味します。+列Nの文字は行が結果に表示されていることを意味し、fileNは、その行(つまり、行はその親の視点から、追加されました)がありません。

In the above example output, the function signature was changed from both files (hence two - removals from both file1 and file2, plus ++ to mean one line that was added does not appear in either file1 or file2). Also eight other lines are the same from file1 but do not appear in file2 (hence prefixed with +).上記の出力例では、関数シグネチャが両方のファイルから変更されました(したがって-、file1とfile2の両方から2つの削除が行われ、加え++て1行がfile1とfile2のどちらにも表示されません)。他の8行もfile1と同じですが、file2には現れません(したがって接頭辞は接頭辞となります+)。

When shown by git diff-tree -c, it compares the parents of a merge commit with the merge result (i.e. file1..fileN are the parents). When shown by git diff-files -c, it compares the two unresolved merge parents with the working tree file (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka "their version").で示されるときgit diff-tree -c、マージコミットの親とマージ結果を比較します(つまり、file1..fileNが親です)。で示されるときgit diff-files -c、それは2つの未解決のマージ親をワーキングツリーファイルと比較します(すなわち、file1はステージ2、別名「our version」、file2はステージ3、別名「彼らのバージョン」です)。

other diff formats他の差分フォーマット

The --summary option describes newly added, deleted, renamed and copied files. The --stat option adds diffstat(1) graph to the output. These options can be combined with other options, such as -p, and are meant for human consumption.この--summaryオプションは、新しく追加、削除、名前変更、およびコピーされたファイルを説明します。この--statオプションはdiffstat(1)グラフを出力に追加します。これらのオプションは、のような他のオプションと組み合わせることができ-p、人間の消費のためのものです。

When showing a change that involves a rename or a copy, --stat output formats the pathnames compactly by combining common prefix and suffix of the pathnames. For example, a change that moves arch/i386/Makefile to arch/x86/Makefile while modifying 4 lines will be shown like this:名前の変更またはコピーを伴う変更を表示するとき、--stat出力はパス名の共通の接頭部と接尾部を組み合わせることによってパス名をコンパクトにフォーマットします。たとえば、4行を変更arch/i386/Makefilearch/x86/Makefileながら移動すると、次のようになります。

arch/{i386 => x86}/Makefile    |   4 +--

The --numstat option gives the diffstat(1) information but is designed for easier machine consumption. An entry in --numstat output looks like this:この--numstatオプションはdiffstat(1)の情報を提供しますが、マシンの消費を容易にするために設計されています。--numstat出力のエントリは次のようになります。

1	2	README
3	1	arch/{i386 => x86}/Makefile

That is, from left to right:つまり、左から右へ:

  1. the number of added lines;追加された行数

  2. a tab;タブ。

  3. the number of deleted lines;削除された行数

  4. a tab;タブ。

  5. pathname (possibly with rename/copy information);パス名(おそらくリネーム/コピー情報付き)。

  6. a newline.改行

When -z output option is in effect, the output is formatted this way:ときに-z、出力オプションが有効である、出力はこのようにフォーマットされます。

1	2	README NUL
3	1	NUL arch/i386/Makefile NUL arch/x86/Makefile NUL

That is:あれは:

  1. the number of added lines;追加された行数

  2. a tab;タブ。

  3. the number of deleted lines;削除された行数

  4. a tab;タブ。

  5. a NUL (only exists if renamed/copied);NUL(名前を変更/コピーした場合にのみ存在します)。

  6. pathname in preimage;プリイメージのパス名。

  7. a NUL (only exists if renamed/copied);NUL(名前を変更/コピーした場合にのみ存在します)。

  8. pathname in postimage (only exists if renamed/copied);postimage内のパス名(名前変更またはコピーされた場合にのみ存在します)。

  9. a NUL.NUL

The extra NUL before the preimage path in renamed case is to allow scripts that read the output to tell if the current record being read is a single-path record or a rename/copy record without reading ahead. After reading added and deleted lines, reading up to NUL would yield the pathname, but if that is NUL, the record will show two paths.名前NULが変更された場合のプリイメージパスの前の余分な部分は、出力を読み取るスクリプトが、先読みせずに、読み取られている現在のレコードがシングルパスレコードか名前変更/コピーレコードかを判断できるようにすることです。追加された行と削除された行を読み取った後、まで読み取るとNULパス名が生成されますが、その場合NUL、レコードには2つのパスが表示されます。

EXAMPLES

Various ways to check your working tree 作業ツリーを確認するためのさまざまな方法
$ git diff            (1)
$ git diff --cached   (2)
$ git diff HEAD       (3)
  1. Changes in the working tree not yet staged for the next commit.作業ツリーの変更はまだ次のコミットには向けられていません。

  2. Changes between the index and your last commit; what you would be committing if you run "git commit" without "-a" option.インデックスと前回のコミットの間の変更。"-a"オプションを指定せずに "git commit"を実行した場合にコミットする内容

  3. Changes in the working tree since your last commit; what you would be committing if you run "git commit -a"最後のコミット以降の作業ツリーの変更。"git commit -a"を実行した場合にコミットするもの

Comparing with arbitrary commits 任意のコミットと比較する
$ git diff test            (1)
$ git diff HEAD -- ./test  (2)
$ git diff HEAD^ HEAD      (3)
  1. Instead of using the tip of the current branch, compare with the tip of "test" branch.現在のブランチの先端を使用する代わりに、 "test"ブランチの先端と比較してください。

  2. Instead of comparing with the tip of "test" branch, compare with the tip of the current branch, but limit the comparison to the file "test"."test"ブランチの先端と比較する代わりに、現在のブランチの先端と比較しますが、比較は "test"ファイルに限定します。

  3. Compare the version before the last commit and the last commit.最後のコミット前と最後のコミット前のバージョンを比較してください。

Comparing branches 枝を比較する
$ git diff topic master    (1)
$ git diff topic..master   (2)
$ git diff topic...master  (3)
  1. Changes between the tips of the topic and the master branches.トピックのヒントとマスターブランチの間の変更。

  2. Same as above.同上。

  3. Changes that occurred on the master branch since when the topic branch was started off it.トピックブランチが開始されてからマスターブランチで発生した変更。

Limiting the diff output 差分出力を制限する
$ git diff --diff-filter=MRC            (1)
$ git diff --name-status                (2)
$ git diff arch/i386 include/asm-i386   (3)
  1. Show only modification, rename, and copy, but not addition or deletion.変更、名前変更、およびコピーだけを表示し、追加または削除は表示しません。

  2. Show only names and the nature of change, but not actual diff output.名前と変更の性質のみを表示し、実際の差分出力は表示しません。

  3. Limit diff output to named subtrees.差分出力を名前付きサブツリーに制限します。

Munging the diff output 差分出力を無効にする
$ git diff --find-copies-harder -B -C  (1)
$ git diff -R                          (2)
  1. Spend extra cycles to find renames, copies and complete rewrites (very expensive).名前の変更、コピー、および完全な書き換えを見つけるために余分なサイクルを費やす(非常に高価)。

  2. Output diff in reverse.逆にdiffを出力します。

SEE ALSO関連項目

diff(1), git-difftool[1], git-log[1], gitdiffcore[7], git-format-patch[1], git-apply[1]diff(1)、git-difftool [1]git-log [1]gitdiffcore [7]git-format-patch [1]git-apply [1]

GIT

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

関連記事

スポンサーリンク

register_object() テンプレート内で使用するオブジェクトを登録します

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

上に戻る