apply

NAME

git-apply - Apply a patch to files and/or to the indexgit-apply - パッチをファイルやインデックスに適用する

SYNOPSIS概要

git apply [--stat] [--numstat] [--summary] [--check] [--index | --intent-to-add] [--3way]
	  [--apply] [--no-add] [--build-fake-ancestor=<file>] [-R | --reverse]
	  [--allow-binary-replacement | --binary] [--reject] [-z]
	  [-p<n>] [-C<n>] [--inaccurate-eof] [--recount] [--cached]
	  [--ignore-space-change | --ignore-whitespace]
	  [--whitespace=(nowarn|warn|fix|error|error-all)]
	  [--exclude=<path>] [--include=<path>] [--directory=<root>]
	  [--verbose] [--unsafe-paths] [<patch>…​]

DESCRIPTION説明

Reads the supplied diff output (i.e. "a patch") and applies it to files. When running from a subdirectory in a repository, patched paths outside the directory are ignored. With the --index option the patch is also applied to the index, and with the --cached option the patch is only applied to the index. Without these options, the command applies the patch only to files, and does not require them to be in a Git repository.与えられた差分出力(すなわち "パッチ")を読み込み、それをファイルに適用します。リポジトリ内のサブディレクトリから実行している場合、ディレクトリ外のパッチを適用したパスは無視されます。--indexオプションのパッチは、インデックスに適用され、と--cachedオプションのパッチは、インデックスのみに適用されます。これらのオプションを指定しないと、コマンドはファイルにのみパッチを適用し、それらがGitリポジトリにあることを要求しません。

This command applies the patch but does not create a commit. Use git-am[1] to create commits from patches generated by git-format-patch[1] and/or received by email.このコマンドはパッチを適用しますが、コミットは作成しません。git-format-patch [1]で生成されたパッチやEメールで受信されたパッチからコミットを作成するには、git-am [1]を使用してください。

OPTIONSオプション

<patch>…​ <パッチ>…

The files to read the patch from. - can be used to read from the standard input.パッチを読むためのファイル。-標準入力から読み込むために使用できます。

--stat - スタット

Instead of applying the patch, output diffstat for the input. Turns off "apply".パッチを適用する代わりに、入力に対してdiffstatを出力します。「適用」をオフにします。

--numstat

Similar to --stat, but shows the number of added and deleted lines in decimal notation and the pathname without abbreviation, to make it more machine friendly. For binary files, outputs two - instead of saying 0 0. Turns off "apply".に似て--statいますが、追加した行と削除した行の数を10進数で表示し、パス名を省略形で表示します。これにより、より使いやすくなります。バイナリファイルの場合は、-言う代わりに2 を出力します0 0。「適用」をオフにします。

--summary - 概要

Instead of applying the patch, output a condensed summary of information obtained from git diff extended headers, such as creations, renames and mode changes. Turns off "apply".パッチを適用する代わりに、作成、名前の変更、モードの変更など、git diff拡張ヘッダから取得した情報の要約を出力します。「適用」をオフにします。

--check - チェック

Instead of applying the patch, see if the patch is applicable to the current working tree and/or the index file and detects errors. Turns off "apply".パッチを適用する代わりに、そのパッチが現在の作業ツリーやインデックスファイル、あるいはその両方に適用可能かどうかを確認し、エラーを検出してください。「適用」をオフにします。

--index - インデックス

When --check is in effect, or when applying the patch (which is the default when none of the options that disables it is in effect), make sure the patch is applicable to what the current index file records. If the file to be patched in the working tree is not up to date, it is flagged as an error. This flag also causes the index file to be updated.とき--check(それが有効である無効のオプションのどれデフォルトではありません)パッチを適用する際に有効である、または、パッチがどのような現在のインデックスファイル・レコードに適用されることを確認してください。作業ツリーにパッチを当てるファイルが最新のものでない場合は、エラーとしてフラグが立てられます。このフラグはインデックスファイルも更新されます。

--cached - キャッシュ

Apply a patch without touching the working tree. Instead take the cached data, apply the patch, and store the result in the index without using the working tree. This implies --index.作業ツリーに触れずにパッチを適用してください。代わりに、キャッシュされたデータを取得し、パッチを適用し、そして作業ツリーを使用せずに結果をインデックスに格納します。これは意味し--indexます。

--intent-to-add

When applying the patch only to the working tree, mark new files to be added to the index later (see --intent-to-add option in git-add[1]). This option is ignored unless running in a Git repository and --index is not specified. Note that --index could be implied by other options such as --cached or --3way.作業ツリーにのみパッチを適用するときは、後でインデックスに追加する新しいファイルをマークします(git-add [1]の--intent-to-addオプションを参照)。このオプションは、Gitリポジトリで実行されていない限り無視され、指定されていません。またはのような他のオプションによって暗示される可能性があることに注意してください。--index--index--cached--3way

-3
--3way - 3ウェイ

When the patch does not apply cleanly, fall back on 3-way merge if the patch records the identity of blobs it is supposed to apply to, and we have those blobs available locally, possibly leaving the conflict markers in the files in the working tree for the user to resolve. This option implies the --index option, and is incompatible with the --reject and the --cached options.パッチがきれいに適用されないとき、パッチがそれが適用されることになっているBLOBのアイデンティティを記録するならば3-wayマージに頼りなさい、そして作業ツリーのファイルに衝突マーカーを残すユーザーが解決するため。このオプションは、意味--indexのオプションを、と互換性がありません--rejectし、--cachedオプション。

--build-fake-ancestor=<file> --build-fake-ancestor = <ファイル>

Newer git diff output has embedded index information for each blob to help identify the original version that the patch applies to. When this flag is given, and if the original versions of the blobs are available locally, builds a temporary index containing those blobs.新しいgit diffの出力には、パッチが適用される元のバージョンを識別するのに役立つように、各BLOBのインデックス情報が埋め込まれています。このフラグが与えられたとき、そしてオリジナルのバージョンのBLOBがローカルで利用可能な場合、それらのBLOBを含む一時的なインデックスを構築します。

When a pure mode change is encountered (which has no index information), the information is read from the current index instead.純粋なモードの変更(インデックス情報がない)が発生すると、情報は現在のインデックスから代わりに読み込まれます。

-R
--reverse - 逆

Apply the patch in reverse.逆にパッチを適用してください。

--reject - 拒否

For atomicity, git apply by default fails the whole patch and does not touch the working tree when some of the hunks do not apply. This option makes it apply the parts of the patch that are applicable, and leave the rejected hunks in corresponding *.rej files.原子性のために、デフォルトでgit applyはパッチ全体を失敗させ、いくつかのハンクが適用されないときに作業ツリーに触れません。このオプションは、適用可能なパッチの部分を適用し、拒否されたハンクを対応する* .rejファイルに残します。

-z

When --numstat has been given, do not munge pathnames, but use a NUL-terminated machine-readable format.--numstat与えられたら、パス名を曖昧にしないで、NUL終了の機械可読フォーマットを使用してください。

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]を参照)。

-p<n> -p <n>

Remove <n> leading path components (separated by slashes) from traditional diff paths. E.g., with -p2, a patch against a/dir/file will be applied directly to file. The default is 1.従来の差分パスから(スラッシュで区切られた)<n>個の先行パスコンポーネントを削除します。例えば、with -p2、に対するパッチa/dir/fileが直接適用されfileます。デフォルトは1です。

-C<n> -C <n>

Ensure at least <n> lines of surrounding context match before and after each change. When fewer lines of surrounding context exist they all must match. By default no context is ever ignored.各変更の前後に、少なくとも<n>行の前後の文脈が一致するようにしてください。周囲の文脈の行が少ない場合、それらはすべて一致しなければなりません。デフォルトでは、コンテキストは無視されません。

--unidiff-zero

By default, git apply expects that the patch being applied is a unified diff with at least one line of context. This provides good safety measures, but breaks down when applying a diff generated with --unified=0. To bypass these checks use --unidiff-zero.デフォルトでは、git applyは適用されるパッチが少なくとも1行のコンテキストを持つ統一された差分であることを期待します。これは良い安全対策を提供しますが、で生成された差分を適用するときに故障し--unified=0ます。これらのチェックが使用バイパスします--unidiff-zero

Note, for the reasons stated above usage of context-free patches is discouraged.上記の理由により、コンテキストフリーパッチの使用はお勧めできません。

--apply - 申し込み

If you use any of the options marked "Turns off apply" above, git apply reads and outputs the requested information without actually applying the patch. Give this flag after those flags to also apply the patch.上記の「適用を無効にする」とマークされたオプションのいずれかを使用すると、git applyは実際にパッチを適用せずに要求された情報を読み込んで出力します。これらのフラグの後にこのフラグを付けてパッチも適用してください。

--no-add

When applying a patch, ignore additions made by the patch. This can be used to extract the common part between two files by first running diff on them and applying the result with this option, which would apply the deletion part but not the addition part.パッチを適用するときは、パッチによる追加を無視してください。これは、最初にdiffを実行し、このオプションで結果を適用することによって2つのファイル間の共通部分を抽出するために使用できます。これは削除部分を適用しますが追加部分は適用しません。

--allow-binary-replacement
--binary - バイナリ

Historically we did not allow binary patch applied without an explicit permission from the user, and this flag was the way to do so. Currently we always allow binary patch application, so this is a no-op.これまでは、ユーザーからの明示的な許可なしにバイナリパッチの適用を許可していませんでした。このフラグがその方法です。現在、私たちは常にバイナリパッチの適用を許可しているので、これは何もしません。

--exclude=<path-pattern> --exclude = <パスパターン>

Don’t apply changes to files matching the given path pattern. This can be useful when importing patchsets, where you want to exclude certain files or directories.与えられたパスパターンと一致するファイルに変更を適用しません。これは、特定のファイルやディレクトリを除外したいパッチセットをインポートするときに便利です。

--include=<path-pattern> --include = <パスパターン>

Apply changes to files matching the given path pattern. This can be useful when importing patchsets, where you want to include certain files or directories.与えられたパスパターンと一致するファイルに変更を適用します。これは、特定のファイルやディレクトリを含めたいパッチセットをインポートするときに便利です。

When --exclude and --include patterns are used, they are examined in the order they appear on the command line, and the first match determines if a patch to each path is used. A patch to a path that does not match any include/exclude pattern is used by default if there is no include pattern on the command line, and ignored if there is any include pattern.--exclude--includeパターンが使用されるとき、それらはコマンドラインに現れる順番で調べられ、最初の一致は各パスへのパッチが使用されるかどうかを決定します。どの包含/除外パターンとも一致しないパスへのパッチは、コマンド行に包含パターンがない場合はデフォルトで使用され、包含パターンがある場合は無視されます。

--ignore-space-change
--ignore-whitespace

When applying a patch, ignore changes in whitespace in context lines if necessary. Context lines will preserve their whitespace, and they will not undergo whitespace fixing regardless of the value of the --whitespace option. New lines will still be fixed, though.パッチを適用するときは、必要に応じてコンテキスト行の空白の変更を無視してください。コンテキスト行は空白を保持し、--whitespaceオプションの値に関係なく空白の修正は行われません。ただし、改行は修正されます。

--whitespace=<action> --whitespace = <アクション>

When applying a patch, detect a new or modified line that has whitespace errors. What are considered whitespace errors is controlled by core.whitespace configuration. By default, trailing whitespaces (including lines that solely consist 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.パッチを適用するときは、空白エラーのある新しい行または変更された行を検出してください。空白エラーと見なされるものはcore.whitespace構成によって制御されます。デフォルトでは、末尾の空白(空白のみで構成されている行を含む)およびその行の最初のインデントの内側にタブ文字が直後に続く空白文字は空白エラーと見なされます。

By default, the command outputs warning messages but applies the patch. When git-apply is used for statistics and not applying a patch, it defaults to nowarn.デフォルトでは、このコマンドは警告メッセージを出力しますが、パッチを適用します。git-applyが統計に使用され、パッチを適用していない場合は、にデフォルト設定されnowarnます。

You can use different <action> values to control this behavior:<action>この動作を制御するためにさまざまな値を使用できます。

  • nowarn turns off the trailing whitespace warning.nowarn 末尾の空白警告をオフにします。

  • warn outputs warnings for a few such errors, but applies the patch as-is (default).warn そのようないくつかのエラーに対して警告を出力しますが、パッチをそのまま適用します(デフォルト)。

  • fix outputs warnings for a few such errors, and applies the patch after fixing them (strip is a synonym --- the tool used to consider only trailing whitespace characters as errors, and the fix involved stripping them, but modern Gits do more).fix出力数このようなエラーに対する警告、およびそれらを固定した後、パッチを適用するには、(strip同義語---のみエラーとして空白文字を末尾に考えるために使用されるツールであり、修正が関与ストリッピングして、しかし、現代のGITSはもっとやります)。

  • error outputs warnings for a few such errors, and refuses to apply the patch.error そのようないくつかのエラーに対して警告を出力し、パッチの適用を拒否します。

  • error-all is similar to error but shows all errors.error-allに似てerrorいますが、すべてのエラーを表示します。

--inaccurate-eof

Under certain circumstances, some versions of diff do not correctly detect a missing new-line at the end of the file. As a result, patches created by such diff programs do not record incomplete lines correctly. This option adds support for applying such patches by working around this bug.特定の状況下では、diffのいくつかのバージョンはファイルの末尾に行方不明の改行を正しく検出しません。結果として、そのようなdiffプログラムによって作成されたパッチは不完全な行を正しく記録しません。このオプションはこのバグを回避することによってそのようなパッチを適用するためのサポートを追加します。

-v
--verbose - 冗談

Report progress to stderr. By default, only a message about the current patch being applied will be printed. This option will cause additional information to be reported.進捗をstderrに報告します。デフォルトでは、現在適用されているパッチに関するメッセージだけが印刷されます。このオプションは追加情報を報告します。

--recount - 再カウント

Do not trust the line counts in the hunk headers, but infer them by inspecting the patch (e.g. after editing the patch without adjusting the hunk headers appropriately).ハンクヘッダー内の行数を信頼しないで、パッチを調べることによってそれらを推測します(たとえば、ハンクヘッダーを適切に調整せずにパッチを編集した後など)。

--directory=<root> --directory = <ルート>

Prepend <root> to all filenames. If a "-p" argument was also passed, it is applied before prepending the new root.すべてのファイル名の前に<root>を付けます。"-p"引数も渡された場合は、新しいルートの前に適用されます。

For example, a patch that talks about updating a/git-gui.sh to b/git-gui.sh can be applied to the file in the working tree modules/git-gui/git-gui.sh by running git apply --directory=modules/git-gui.たとえば、更新について語ったパッチa/git-gui.shには、b/git-gui.sh作業ツリー内のファイルに適用することができますmodules/git-gui/git-gui.sh実行することによってgit apply --directory=modules/git-gui

--unsafe-paths

By default, a patch that affects outside the working area (either a Git controlled working tree, or the current working directory when "git apply" is used as a replacement of GNU patch) is rejected as a mistake (or a mischief).デフォルトでは、作業領域の外側(Gitで管理された作業ツリー、または "git apply"がGNUパッチの代わりとして使用されている場合は現在の作業ディレクトリ)に影響を及ぼすパッチは間違い(またはいたずら)として拒否されます。

When git apply is used as a "better GNU patch", the user can pass the --unsafe-paths option to override this safety check. This option has no effect when --index or --cached is in use.git applyが「より良いGNUパッチ」として使用されている場合、ユーザーは--unsafe-pathsこの安全性チェックを無効にするオプションを渡すことができます。このオプションは使用中--indexまたは--cached使用中には効果がありません。

CONFIGURATION設定

apply.ignoreWhitespace

Set to change if you want changes in whitespace to be ignored by default. Set to one of: no, none, never, false if you want changes in whitespace to be significant.空白の変更をデフォルトで無視したい場合は、changeに設定します。空白の変更を重要にしたい場合は、no、none、never、falseのいずれかに設定します。

apply.whitespace

When no --whitespace flag is given from the command line, this configuration item is used as the default.--whitespaceコマンドラインからフラグが指定されていない場合は、この設定項目がデフォルトとして使用されます。

SUBMODULESサブモジュール

If the patch contains any changes to submodules then git apply treats these changes as follows.パッチにサブモジュールへの変更が含まれている場合、git applyはこれらの変更を次のように扱います。

If --index is specified (explicitly or implicitly), then the submodule commits must match the index exactly for the patch to apply. If any of the submodules are checked-out, then these check-outs are completely ignored, i.e., they are not required to be up to date or clean and they are not updated.--indexが明示的または暗黙的に指定されている場合、サブモジュールのコミットは、適用するパッチに対して正確にインデックスと一致する必要があります。いずれかのサブモジュールがチェックアウトされている場合、これらのチェックアウトは完全に無視されます。つまり、それらのサブモジュールを最新の状態にしたりクリーンにしたりする必要はなく、更新もされません。

If --index is not specified, then the submodule commits in the patch are ignored and only the absence or presence of the corresponding subdirectory is checked and (if possible) updated.--indexが指定されていない場合は、パッチ内のサブモジュールコミットは無視され、対応するサブディレクトリの有無のみがチェックされ、(可能であれば)更新されます。

SEE ALSO関連項目

git-am[1].gitの-AM [1]

GIT

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

関連記事

スポンサーリンク

COALESCE関数 NULL値でない最初の引数を返す

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

上に戻る