add

NAME

git-add - Add file contents to the indexgit-add - ファイルの内容をインデックスに追加する

SYNOPSIS概要

git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p]
	  [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]]
	  [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--renormalize]
	  [--chmod=(+|-)x] [--] [<pathspec>…​]

DESCRIPTION説明

This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit. It typically adds the current content of existing paths as a whole, but with some options it can also be used to add content with only part of the changes made to the working tree files applied, or remove paths that do not exist in the working tree anymore.このコマンドは、作業ツリーにある現在のコンテンツを使用してインデックスを更新し、次のコミットに備えてステージングされたコンテンツを準備します。通常は既存のパスの現在の内容を全体として追加しますが、一部のオプションでは、作業ツリーファイルに加えられた変更の一部のみを適用して内容を追加したり、作業ツリーに存在しないパスを削除したりできます。もう。

The "index" holds a snapshot of the content of the working tree, and it is this snapshot that is taken as the contents of the next commit. Thus after making any changes to the working tree, and before running the commit command, you must use the add command to add any new or modified files to the index."index"は作業ツリーの内容のスナップショットを保持していて、それが次のコミットの内容となるのがこのスナップショットです。したがって、作業ツリーに変更を加えた後、そしてcommitコマンドを実行する前に、このaddコマンドを使用して新しいファイルまたは変更されたファイルをインデックスに追加する必要があります。

This command can be performed multiple times before a commit. It only adds the content of the specified file(s) at the time the add command is run; if you want subsequent changes included in the next commit, then you must run git add again to add the new content to the index.このコマンドはコミット前に複数回実行できます。addコマンドが実行されたときに、指定されたファイルの内容を追加するだけです。その後の変更を次回のコミットに含める場合は、git add再度実行して新しいコンテンツをインデックスに追加する必要があります。

The git status command can be used to obtain a summary of which files have changes that are staged for the next commit.このgit statusコマンドを使用して、次のコミットのためにどのファイルに変更があるかの要約を取得できます。

The git add command will not add ignored files by default. If any ignored files were explicitly specified on the command line, git add will fail with a list of ignored files. Ignored files reached by directory recursion or filename globbing performed by Git (quote your globs before the shell) will be silently ignored. The git add command can be used to add ignored files with the -f (force) option.このgit addコマンドはデフォルトで無視されるファイルを追加しません。無視されたファイルがコマンドラインで明示的に指定されているgit addと、無視されたファイルのリストで失敗します。ディレクトリの再帰やGitによって実行されたファイル名グロブ(シェルの前にグロブを引用)によって到達された無視されたファイルは黙って無視されます。gitの追加コマンドは無視して、ファイルを追加するために使用することができます-f(強制)オプション。

Please see git-commit[1] for alternative ways to add content to a commit.コミットに内容を追加する別の方法についてはgit-commit [1]を見てください。

OPTIONSオプション

<pathspec>…​ <pathspec>…

Files to add content from. Fileglobs (e.g. *.c) can be given to add all matching files. Also a leading directory name (e.g. dir to add dir/file1 and dir/file2) can be given to update the index to match the current state of the directory as a whole (e.g. specifying dir will record not just a file dir/file1 modified in the working tree, a file dir/file2 added to the working tree, but also a file dir/file3 removed from the working tree). Note that older versions of Git used to ignore removed files; use --no-all option if you want to add modified or new files but ignore removed ones.コンテンツを追加するファイル。ファイルグロブ(例*.c)を指定すると、一致するすべてのファイルを追加できます。また、ディレクトリ全体の現在の状態に一致するようにインデックスを更新するために、先頭のディレクトリ名(dir追加dir/file1や追加などdir/file2)を指定することができます(指定するdirdir/file1、作業ツリーで変更されたファイルだけではなく作業ファイルにdir/file2追加されます)。ツリーだけでなくdir/file3、作業ツリーから削除されたファイルもあります。以前のバージョンのGitは削除されたファイルを無視していました。--no-all修正したファイルや新しいファイルを追加したいが削除したファイルは無視したい場合はオプションを使用してください。

For more details about the <pathspec> syntax, see the pathspec entry in gitglossary[7].<pathspec>構文の詳細については、gitglossary [7]のpathspecエントリを参照してください。

-n
--dry-run

Don’t actually add the file(s), just show if they exist and/or will be ignored.実際にファイルを追加するのではなく、それらが存在するかどうかを示すだけで、無視されます。

-v
--verbose - 冗談

Be verbose.冗長になります。

-f
--force - 力

Allow adding otherwise ignored files.それ以外の場合は無視されるファイルの追加を許可

-i -私
--interactive - インタラクティブ

Add modified contents in the working tree interactively to the index. Optional path arguments may be supplied to limit operation to a subset of the working tree. See “Interactive mode” for details.作業ツリーの変更内容を対話式に索引に追加します。作業ツリーのサブセットに操作を制限するために、オプションのパス引数を指定できます。詳細は「インタラクティブモード」をご覧ください。

-p
--patch - パッチ

Interactively choose hunks of patch between the index and the work tree and add them to the index. This gives the user a chance to review the difference before adding modified contents to the index.インデックスと作業ツリーの間の対話的に大量のパッチを選択し、それらをインデックスに追加します。これにより、変更されたコンテンツをインデックスに追加する前に、違いを確認することができます。

This effectively runs add --interactive, but bypasses the initial command menu and directly jumps to the patch subcommand. See “Interactive mode” for details.これは効果的に実行されadd --interactiveますが、最初のコマンドメニューをバイパスして直接patchサブコマンドにジャンプします。詳細は「インタラクティブモード」をご覧ください。

-e
--edit - 編集

Open the diff vs. the index in an editor and let the user edit it. After the editor was closed, adjust the hunk headers and apply the patch to the index.差分とインデックスをエディタで開き、ユーザに編集させます。エディタを閉じた後、ハンクヘッダを調整してパッチをインデックスに適用します。

The intent of this option is to pick and choose lines of the patch to apply, or even to modify the contents of lines to be staged. This can be quicker and more flexible than using the interactive hunk selector. However, it is easy to confuse oneself and create a patch that does not apply to the index. See EDITING PATCHES below.このオプションの目的は、適用するパッチの行を選択して選択すること、またはステージングする行の内容を変更することです。これは、インタラクティブなハンクセレクタを使用するよりも速くて柔軟性があります。ただし、自分自身を混乱させ、インデックスに適用されないパッチを作成するのは簡単です。下記のパッチの編集を参照してください。

-u
--update - 更新

Update the index just where it already has an entry matching <pathspec>. This removes as well as modifies index entries to match the working tree, but adds no new files.<pathspec>に一致するエントリがすでにある場所でインデックスを更新します。これにより、インデックスエントリが削除され、作業ツリーと一致するように変更されますが、新しいファイルは追加されません。

If no <pathspec> is given when -u option is used, all tracked files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).-uoptionが使用されているときに<pathspec>が指定されていない場合は、作業ツリー全体のすべての追跡ファイルが更新されます(Gitの古いバージョンは現在のディレクトリとそのサブディレクトリに更新を制限するために使用されます)。

-A
--all - すべて
--no-ignore-removal

Update the index not only where the working tree has a file matching <pathspec> but also where the index already has an entry. This adds, modifies, and removes index entries to match the working tree.作業ツリーに<pathspec>と一致するファイルがある場合だけでなく、インデックスにすでにエントリがある場合もインデックスを更新します。これは、作業ツリーと一致するようにインデックスエントリを追加、修正、削除します。

If no <pathspec> is given when -A option is used, all files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).-Aoptionの使用時に<pathspec>が指定されていないと、作業ツリー全体のすべてのファイルが更新されます(Gitの古いバージョンでは、現在のディレクトリとそのサブディレクトリに更新を制限していました)。

--no-all - 全部なし
--ignore-removal

Update the index by adding new files that are unknown to the index and files modified in the working tree, but ignore files that have been removed from the working tree. This option is a no-op when no <pathspec> is used.作業ツリーで変更されたインデックスとファイルに未知の新しいファイルを追加して、作業ツリーから削除されたファイルを無視して、インデックスを更新します。<pathspec>が使用されていない場合、このオプションは何もしません。

This option is primarily to help users who are used to older versions of Git, whose "git add <pathspec>…​" was a synonym for "git add --no-all <pathspec>…​", i.e. ignored removed files.このオプションは主にGitの古いバージョンに慣れているユーザーを助けるためのものです。その "git add <pathspec>…"は "git add --no-all <pathspec>…"の同義語で、削除されたファイルは無視されます。

-N
--intent-to-add

Record only the fact that the path will be added later. An entry for the path is placed in the index with no content. This is useful for, among other things, showing the unstaged content of such files with git diff and committing them with git commit -a.パスが後で追加されるという事実だけを記録します。パスのエントリは、コンテンツなしでインデックスに配置されます。これは、とりわけ、そのようなファイルのステージングされていないコンテンツを表示しgit diffたりコミットしたりするのに役立ちますgit commit -a

--refresh - リフレッシュ

Don’t add the file(s), but only refresh their stat() information in the index.ファイルを追加しないで、インデックス内のそれらのstat()情報のみを更新してください。

--ignore-errors

If some files could not be added because of errors indexing them, do not abort the operation, but continue adding the others. The command shall still exit with non-zero status. The configuration variable add.ignoreErrors can be set to true to make this the default behaviour.索引付けエラーのためにいくつかのファイルを追加できなかった場合は、操作を中止せずに他のファイルの追加を続けます。コマンドはまだゼロ以外のステータスで終了します。add.ignoreErrorsこれをデフォルトの動作にするには、構成変数をtrueに設定します。

--ignore-missing

This option can only be used together with --dry-run. By using this option the user can check if any of the given files would be ignored, no matter if they are already present in the work tree or not.このオプションは--dry-runと一緒にしか使用できません。このオプションを使用することによって、ユーザーは与えられたファイルのいずれかが無視されるかどうかをチェックすることができます。

--no-warn-embedded-repo

By default, git add will warn when adding an embedded repository to the index without using git submodule add to create an entry in .gitmodules. This option will suppress the warning (e.g., if you are manually performing operations on submodules).デフォルトでgit addgit submodule add、にエントリを作成するのに使わずに埋め込みリポジトリをインデックスに追加するときに警告します.gitmodules。このオプションは警告を抑制します(たとえば、サブモジュールに対して手動で操作を実行している場合など)。

--renormalize - ノーマライズ

Apply the "clean" process freshly to all tracked files to forcibly add them again to the index. This is useful after changing core.autocrlf configuration or the text attribute in order to correct files added with wrong CRLF/LF line endings. This option implies -u.追跡されているすべてのファイルに新たに「クリーン」プロセスを適用して、それらを強制的に再度インデックスに追加します。間違ったCRLF / LFの行末で追加されたファイルを修正するためにcore.autocrlf設定やtext属性を変更した後にこれは役に立ちます。このオプションは意味し-uます。

--chmod=(+|-)x --chmod =(+ | - )x

Override the executable bit of the added files. The executable bit is only changed in the index, the files on disk are left unchanged.追加したファイルの実行可能ビットを上書きします。実行可能ビットはインデックス内でのみ変更され、ディスク上のファイルは変更されません。

-- -

This option can be used to separate command-line options from the list of files, (useful when filenames might be mistaken for command-line options).このオプションは、ファイルのリストからコマンドラインオプションを分離するために使用できます(ファイル名がコマンドラインオプションと間違えられる可能性がある場合に役立ちます)。

CONFIGURATION設定

The optional configuration variable core.excludesFile indicates a path to a file containing patterns of file names to exclude from git-add, similar to $GIT_DIR/info/exclude. Patterns in the exclude file are used in addition to those in info/exclude. See gitignore[5].オプションの設定変数core.excludesFileは、$ GIT_DIR / info / excludeのように、git-addから除外するファイル名のパターンを含むファイルへのパスを示します。除外ファイル内のパターンは、info / exclude内のパターンに加えて使用されます。gitignore [5]を参照してください。

EXAMPLES

  • Adds content from all *.txt files under Documentation directory and its subdirectories:ディレクトリとそのサブディレクトリの*.txt下にあるすべてのファイルからコンテンツを追加しますDocumentation

    $ git add Documentation/\*.txt

    Note that the asterisk * is quoted from the shell in this example; this lets the command include the files from subdirectories of Documentation/ directory.*この例では、アスタリスクがシェルから引用されていることに注意してください。これはコマンドにディレクトリのサブディレクトリからのファイルを含めることを可能にしますDocumentation/

  • Considers adding content from all git-*.sh scripts:すべてのgit - *。shスクリプトからコンテンツを追加することを検討してください。

    $ git add git-*.sh

    Because this example lets the shell expand the asterisk (i.e. you are listing the files explicitly), it does not consider subdir/git-foo.sh.この例ではシェルがアスタリスクを拡張できるようにしているので(つまり、ファイルを明示的にリストしている)、考慮していませんsubdir/git-foo.sh

INTERACTIVE MODE対話モード

When the command enters the interactive mode, it shows the output of the status subcommand, and then goes into its interactive command loop.コマンドが対話モードに入ると、statusサブコマンドの出力が表示されてから、その対話型コマンドループに入ります。

The command loop shows the list of subcommands available, and gives a prompt "What now> ". In general, when the prompt ends with a single >, you can pick only one of the choices given and type return, like this:コマンドループは利用可能なサブコマンドのリストを表示し、プロンプト "What now>"を与えます。一般に、プロンプトが単一の>で終わっている場合は、次のように、与えられた選択肢のうち1つだけを選択してreturnキーを押すことができます。

    *** Commands ***
      1: status       2: update       3: revert       4: add untracked
      5: patch        6: diff         7: quit         8: help
    What now> 1

You also could say s or sta or status above as long as the choice is unique.選択がユニークである限り、あなたはまた言うssta、あるいはそれstatus以上にできます。

The main command loop has 6 subcommands (plus help and quit).メインコマンドループには6つのサブコマンドがあります(さらにhelpとquit)。

status 状態

This shows the change between HEAD and index (i.e. what will be committed if you say git commit), and between index and working tree files (i.e. what you could stage further before git commit using git add) for each path. A sample output looks like this:これはHEADとインデックスの間の変化(つまりあなたが言うならコミットされるものgit commit)、そしてインデックスと作業ツリーファイルの間の変化(すなわちあなたがgit commit使用する前にさらにステージングできるものgit add)を各パスについて示しています。出力例は次のようになります。

              staged     unstaged path
     1:       binary      nothing foo.png
     2:     +403/-35        +1/-1 git-add--interactive.perl

It shows that foo.png has differences from HEAD (but that is binary so line count cannot be shown) and there is no difference between indexed copy and the working tree version (if the working tree version were also different, binary would have been shown in place of nothing). The other file, git-add{litdd}interactive.perl, has 403 lines added and 35 lines deleted if you commit what is in the index, but working tree file has further modifications (one addition and one deletion).それはfoo.pngがHEADと異なることを示しています(しかしそれはバイナリなので行数を表示することはできません)そしてインデックスコピーと作業ツリーのバージョンの間に違いはありません(作業ツリーのバージョンも異なる場合、バイナリは示されるでしょう)何もないところで)。もう1つのファイル、git-add {litdd} interactive.perlには、インデックス内にあるものをコミットすると403行が追加され35行が削除されますが、作業ツリーファイルにはさらに変更が加えられます(1つ追加および1削除)。

update 更新

This shows the status information and issues an "Update>>" prompt. When the prompt ends with double >>, you can make more than one selection, concatenated with whitespace or comma. Also you can say ranges. E.g. "2-5 7,9" to choose 2,3,4,5,7,9 from the list. If the second number in a range is omitted, all remaining patches are taken. E.g. "7-" to choose 7,8,9 from the list. You can say * to choose everything.これはステータス情報を示し、「アップデート>>」プロンプトを発行します。プロンプトが二重の>>で終わったら、空白またはコンマで連結して複数の選択を行うことができます。また範囲を言うことができます。例えば ??"2-5 7,9"はリストから2,3,4,5,7,9を選択します。範囲内の2番目の番号を省略すると、残りのすべてのパッチが取得されます。例えば ??"7-"はリストから7,8,9を選択するためのものです。あなたはすべてを選ぶために*と言うことができます。

What you chose are then highlighted with *, like this:あなたが選んだものは、このように*で強調表示されます

           staged     unstaged path
  1:       binary      nothing foo.png
* 2:     +403/-35        +1/-1 git-add--interactive.perl

To remove selection, prefix the input with - like this:選択を解除するには、入力の前に次の-ように付けます。

Update>> -2

After making the selection, answer with an empty line to stage the contents of working tree files for selected paths in the index.選択したら、空の行で答えて、インデックス内の選択したパスの作業ツリーファイルの内容をステージングします。

revert 元に戻す

This has a very similar UI to update, and the staged information for selected paths are reverted to that of the HEAD version. Reverting new paths makes them untracked.これは更新するのに非常に似たUIを持ち、選択されたパスの段階的な情報はHEADバージョンのものに戻ります。新しい経路を元に戻すと、それらは追跡されなくなります。

add untracked 未追跡を追加

This has a very similar UI to update and revert, and lets you add untracked paths to the index.これは更新元に戻すのに非常によく似たUIを持ち、追跡されていないパスをインデックスに追加することを可能にします。

patch パッチ

This lets you choose one path out of a status like selection. After choosing the path, it presents the diff between the index and the working tree file and asks you if you want to stage the change of each hunk. You can select one of the following options and type return:これにより、選択のようなステータスから1つのパスを選択できます。パスを選択した後、それはインデックスと作業ツリーファイルの間の差分を提示し、あなたがそれぞれの塊の変更をステージングしたいかどうかあなたに尋ねます。次のいずれかのオプションを選択してreturnと入力できます。

y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk or any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk or any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help

After deciding the fate for all hunks, if there is any hunk that was chosen, the index is updated with the selected hunks.すべてのハンクの運命を決定した後、選択されたハンクがある場合は、選択されたハンクでインデックスが更新されます。

You can omit having to type return here, by setting the configuration variable interactive.singleKey to true.設定変数interactive.singleKeyをに設定することで、ここでreturnと入力する手間を省くことができますtrue

diff 差分

This lets you review what will be committed (i.e. between HEAD and index).これにより、コミットされる内容(つまり、HEADとインデックスの間)を確認できます。

EDITING PATCHESパッチを編集する

Invoking git add -e or selecting e from the interactive hunk selector will open a patch in your editor; after the editor exits, the result is applied to the index. You are free to make arbitrary changes to the patch, but note that some changes may have confusing results, or even result in a patch that cannot be applied. If you want to abort the operation entirely (i.e., stage nothing new in the index), simply delete all lines of the patch. The list below describes some common things you may see in a patch, and which editing operations make sense on them.インタラクティブなハンクセレクタを起動git add -eまたは選択するeと、エディタにパッチが開きます。エディタが終了した後、結果はインデックスに適用されます。あなたは自由にパッチに任意の変更を加えることができますが、いくつかの変更が混乱を招く結果をもたらすかもしれない、あるいは適用できないパッチにさえなるかもしれないことに注意してください。操作を完全に中止したい(つまり、インデックスに新しいものを追加したくない)場合は、単にパッチのすべての行を削除してください。以下のリストは、パッチに表示される可能性があるいくつかの一般的なことと、それらに適した編集操作について説明しています。

added content 追加コンテンツ

Added content is represented by lines beginning with "+". You can prevent staging any addition lines by deleting them.追加された内容は、「+」で始まる行で表されます。追加行を削除することで、追加行のステージングを防ぐことができます。

removed content 削除されたコンテンツ

Removed content is represented by lines beginning with "-". You can prevent staging their removal by converting the "-" to a " " (space).削除されたコンテンツは " - "で始まる行で表されます。" - "を ""(スペース)に変換することで、それらが削除されるのを防ぐことができます。

modified content 変更内容

Modified content is represented by "-" lines (removing the old content) followed by "+" lines (adding the replacement content). You can prevent staging the modification by converting "-" lines to " ", and removing "+" lines. Beware that modifying only half of the pair is likely to introduce confusing changes to the index.変更された内容は " - "行(古い内容を削除する)とそれに続く "+"行(置換内容を追加する)で表されます。" - "行を ""に変換し、 "+"行を削除することで、変更の段階付けを防ぐことができます。ペアの半分だけを変更すると、インデックスに混乱を招くような変更が生じる可能性があることに注意してください。

There are also more complex operations that can be performed. But beware that because the patch is applied only to the index and not the working tree, the working tree will appear to "undo" the change in the index. For example, introducing a new line into the index that is in neither the HEAD nor the working tree will stage the new line for commit, but the line will appear to be reverted in the working tree.実行できるより複雑な操作もあります。ただし、パッチは作業ツリーではなくインデックスにのみ適用されるため、作業ツリーはインデックスの変更を「元に戻す」ように見えます。たとえば、HEADにも作業ツリーにもないインデックスに新しい行を導入すると、その新しい行はコミットのためにステージングされますが、その行は作業ツリーで元に戻されるように見えます。

Avoid using these constructs, or do so with extreme caution.これらの構成要素を使用しないようにするか、細心の注意を払って使用してください。

removing untouched content そのままのコンテンツを削除する

Content which does not differ between the index and working tree may be shown on context lines, beginning with a " " (space). You can stage context lines for removal by converting the space to a "-". The resulting working tree file will appear to re-add the content.インデックスと作業ツリーの間で異ならない内容は、 ""(スペース)で始まるコンテキスト行に表示されます。スペースを " - "に変換することで、コンテキスト行を削除用にステージングできます。結果の作業ツリーファイルは、コンテンツを再追加するように見えます。

modifying existing content 既存のコンテンツを変更する

One can also modify context lines by staging them for removal (by converting " " to "-") and adding a "+" line with the new content. Similarly, one can modify "+" lines for existing additions or modifications. In all cases, the new modification will appear reverted in the working tree.また、 ""を " - "に変換して削除するようにステージングし、新しいコンテンツに "+"行を追加することで、コンテキスト行を変更することもできます。同様に、既存の追加や修正のために "+"行を修正することができます。すべての場合において、新しい変更は作業ツリーに戻って表示されます。

new content 新しいコンテンツ

You may also add new content that does not exist in the patch; simply add new lines, each starting with "+". The addition will appear reverted in the working tree.パッチに存在しない新しいコンテンツを追加することもできます。単に "+"で始まる新しい行を追加するだけです。追加は作業ツリーで元に戻されます。

There are also several operations which should be avoided entirely, as they will make the patch impossible to apply:パッチを適用することを不可能にするので、完全に避けるべきいくつかの操作もあります。

  • adding context (" ") or removal ("-") linesコンテキスト( "")行または削除( " - ")行を追加する

  • deleting context or removal linesコンテキストまたは削除行の削除

  • modifying the contents of context or removal linesコンテキストまたは削除行の内容を変更する

SEE ALSO関連項目

git-status[1] git-rm[1] git-reset[1] git-mv[1] git-commit[1] git-update-index[1]git-status [1] git-rm [1] git-reset [1] git-mv [1] git-commit [1] git-update-index [1]

GIT

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

関連記事

スポンサーリンク

<演算子 小さい

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

上に戻る