doc: git-add: clarify intro & add an example

- Add a basic example of how "git add" is normally used - It's not technically true that you *must* use the `add` command to add changes before running `git commit`, because `git commit -a` exists. Instead say that you *can* use the `add` command. - Mention early on that "index" is another word for "staging area", since Git very rarely uses the word "index" in its output (`git status`) uses the term "staged", and many Git users are unfamiliar with the term "index" - Remove "It typically adds" (it's not clear what "typically" means), and instead mention that `git add -p` can be used to add partial contents - Currently the introduction is somewhat repetitive ("to prepare the content staged for the next commit" ... "this snapshot that is taken as the contents of the next commit."), replace with a single sentence ("The "index" [...] is where Git stores the contents of the next commit.") Signed-off-by: Julia Evans <julia@jvns.ca> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Julia Evans committed Aug 19, 2025 at 20:46 UTC d14147c0ab84bf4d08adedb4d1a4e99511c56375
1 file changed +12 -12
Documentation/git-add.adoc
+12 -12
@@ -16,18 +16,18 @@ git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [-
16
17 DESCRIPTION
18 -----------
19 -This command updates the index using the current content found in
20 -the working tree, to prepare the content staged for the next commit.
21 -It typically adds the current content of existing paths as a whole,
22 -but with some options it can also be used to add content with
23 -only part of the changes made to the working tree files applied, or
24 -remove paths that do not exist in the working tree anymore.
25 -
26 -The "index" holds a snapshot of the content of the working tree, and it
27 -is this snapshot that is taken as the contents of the next commit. Thus
28 -after making any changes to the working tree, and before running
29 -the commit command, you must use the `add` command to add any new or
30 -modified files to the index.
19 +Add contents of new or changed files to the index. The "index" (also
20 +known as "staging area") is where Git stores the contents of the next
21 +commit.
22 +
23 +When you run `git commit` without any other arguments, it will only
24 +commit staged changes. For example, if you've edited `file.c` and want
25 +to commit your changes to that file, you can run:
26 +
27 + git add file.c
28 + git commit
29 +
30 +You can also add only part of your changes to a file with `git add -p`.
31
32 This command can be performed multiple times before a commit. It only
33 adds the content of the specified file(s) at the time the add command is