diff --git a/Documentation/git-add.adoc b/Documentation/git-add.adoc index b7a735824d6ce0..0b887e1d60ca84 100644 --- a/Documentation/git-add.adoc +++ b/Documentation/git-add.adoc @@ -3,7 +3,7 @@ git-add(1) NAME ---- -git-add - Add file contents to the index +git-add - Add new or changed files to the index SYNOPSIS -------- @@ -16,37 +16,38 @@ git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [- 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. - -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. - -The `git status` command can be used to obtain a summary of which -files have changes that are staged for the next commit. - -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. - -Please see linkgit:git-commit[1] for alternative ways to add content to a -commit. +Add new or changed files to the index to prepare for a commit. The +"index" (also known as "staging area") is where Git stores the changes +that will be in the next commit. +By default, `git commit` only commits changes that you've added to the +index. For example, if you've edited `file.c` and want to commit your +changes, you can run: + + git add file.c + git commit + +You can also add only part of your changes to a file with `git add -p`. +Please see linkgit:git-commit[1] for alternative ways to add content to +a commit. + +The `git add` command only adds the changes at the time that you run it. +If you edit `file.c` after adding it, you need to run `git add file.c` +again before committing. + +If you want to check which changes have been added, you can run +`git status` to print out a summary of the changes that will be committed +or run `git diff --staged` to see the full diff. + +`git add` will not add ignored files by default. You can use the +`--force` option to add ignored files. If you explicitly specify the +exact filename of an ignored file (e.g. `git add ignored.txt`), `git +add` will fail with a list of ignored files. Otherwise it will silently +ignore the file. + +[NOTE] +Git uses the terms "staging area", "index" and "cache" interchangeably +for historical reasons. OPTIONS ------- @@ -451,6 +452,7 @@ linkgit:git-rm[1] linkgit:git-reset[1] linkgit:git-mv[1] linkgit:git-commit[1] +linkgit:git-diff[1] linkgit:git-update-index[1] GIT