From: Junio C Hamano <gitster@pobox.com>
To: "Julia Evans via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Julia Evans <julia@jvns.ca>
Subject: Re: [PATCH 2/5] doc: git-add: start man page with an example
Date: Tue, 12 Aug 2025 14:01:16 -0700 [thread overview]
Message-ID: <xmqqbjoks19f.fsf@gitster.g> (raw)
In-Reply-To: <310d2c1d8f7f68ae52ddd29f0ccb0a0364aba1a2.1755029249.git.gitgitgadget@gmail.com> (Julia Evans via GitGitGadget's message of "Tue, 12 Aug 2025 20:07:26 +0000")
"Julia Evans via GitGitGadget" <gitgitgadget@gmail.com> writes:
> - Remove the snapshot-based explanation of the index and replace it with
> a diff-based explanation because I don't feel that it's useful in this
> context to emphasize that git uses a snapshot-based model: the main
> way most git users interact with the index is through `git diff` or
> `git status`, which is a completely diff-based view of the index.
But isn't it the source of the most end-user confusion that they
cannot wean themselves off of the diff/patch worldview?
How would you explain what the users would see in their "git diff",
"git diff --cached", and "git commit" after doing "edit && add &&
edit", if you explain "add" to be storing the "diff" made by the
first edit? Does their "git diff" after the second "edit" take that
previously stored "diff" and another "diff" made by the second
"edit" and magically combine them together to present a single
"diff"?
> -git-add - Add file contents to the index
> +git-add - Add new or changed files to the index
In other words, I do think "new or changed" is a good thing to say,
but the word "contents" is fundamental here. "Add contents of new
or changed files to the index" would be good.
> +Add new or changed files to the index (also known as "staging area") to
> +prepare for a commit.
OK, but saying "files" here adds another kind of confusion. What is
"added" is not the fact that these paths are kept track of by Git.
Instead we add the snapshot of the contents at the time of 'git add'.
Wouldn't "add file X" confuse folks who still remember how other
SCMs before Git operated (i.e. "file X is now known, so if I make
further changes to X next 'commit' command will record it") into
thinking that Git would do the same?
> +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
What happens when you did "edit && add && edit && add"? It commits
the two changes you added to the index? I do not think it is
productive to hide the fact that you are preparing a snapshot of the
"next commit" in the index (or "staging the contents for the next
commit in the staging area") with various forms "git add", including
"git add -p".
And to help form that mental model, it would help to avoid phrasing
"commit your changes" (as if you are somehow dealing with "diff/patch")
and instead saying "commit the result of your changes" (stressing
that the "state" matters), I would think.
De-stressing the fact that we are taking a snapshot should probably
be considered a documentation regression here. Thanks to "git add"
taking a snapshot, users can further make experimental changes in
the working tree files freely and then come back to the exact
contents back by checking the path out of the index with "git
checkout -- <path>". Thanks to "git commit" taking a snapshot,
users can even go back to the last commit by taking the exact
contents back by checking the path out of the HEAD with "git
checkout HEAD -- <path>".
I'll stop here and let others express their opinions without further
commenting for now.
Thanks for working on these updates.
next prev parent reply other threads:[~2025-08-12 21:01 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 20:07 [PATCH 0/5] doc: git-add: clarify DESCRIPTION section Julia Evans via GitGitGadget
2025-08-12 20:07 ` [PATCH 1/5] doc: git-add: remove options from SYNOPSIS Julia Evans via GitGitGadget
2025-08-12 20:41 ` Junio C Hamano
2025-08-13 16:58 ` Julia Evans
2025-08-13 20:47 ` Jean-Noël AVILA
2025-08-12 20:07 ` [PATCH 2/5] doc: git-add: start man page with an example Julia Evans via GitGitGadget
2025-08-12 21:01 ` Junio C Hamano [this message]
2025-08-12 21:40 ` Julia Evans
2025-08-12 22:12 ` Junio C Hamano
2025-08-12 22:45 ` Julia Evans
2025-08-13 17:22 ` D. Ben Knoble
2025-08-14 0:41 ` Junio C Hamano
2025-08-14 2:59 ` Julia Evans
2025-08-15 5:38 ` Junio C Hamano
2025-08-12 20:07 ` [PATCH 3/5] doc: git-add: simplify discussion of ignored files Julia Evans via GitGitGadget
2025-08-13 17:24 ` D. Ben Knoble
2025-08-12 20:07 ` [PATCH 4/5] doc: git-add: make explanation less dry Julia Evans via GitGitGadget
2025-08-12 20:07 ` [PATCH 5/5] doc: git-add: explain inconsistent terminology Julia Evans via GitGitGadget
2025-08-12 20:51 ` Chris Torek
2025-08-12 21:36 ` Junio C Hamano
2025-08-12 21:43 ` Julia Evans
2025-08-13 23:20 ` [PATCH v2 0/4] doc: git-add: clarify DESCRIPTION section Julia Evans via GitGitGadget
2025-08-13 23:20 ` [PATCH v2 1/4] doc: git-add: start man page with an example Julia Evans via GitGitGadget
2025-08-15 0:38 ` Junio C Hamano
2025-08-15 13:34 ` Jean-Noël AVILA
2025-08-15 16:33 ` Junio C Hamano
2025-08-17 18:37 ` Jean-Noël AVILA
2025-08-19 20:01 ` Julia Evans
2025-08-13 23:20 ` [PATCH v2 2/4] doc: git-add: simplify discussion of ignored files Julia Evans via GitGitGadget
2025-08-14 0:59 ` D. Ben Knoble
2025-08-14 22:10 ` Junio C Hamano
2025-08-13 23:20 ` [PATCH v2 3/4] doc: git-add: make explanation less dry Julia Evans via GitGitGadget
2025-08-14 22:22 ` Junio C Hamano
2025-08-15 16:10 ` Julia Evans
2025-08-15 18:25 ` D. Ben Knoble
2025-08-15 20:01 ` Junio C Hamano
2025-08-16 14:15 ` D. Ben Knoble
2025-08-15 19:47 ` Junio C Hamano
2025-08-19 12:57 ` Julia Evans
2025-08-21 20:36 ` Jean-Noël AVILA
2025-08-13 23:20 ` [PATCH v2 4/4] doc: git-add: explain inconsistent terminology Julia Evans via GitGitGadget
2025-08-14 22:49 ` Junio C Hamano
2025-08-19 20:09 ` Julia Evans
2025-08-19 20:46 ` [PATCH v3 0/3] doc: git-add: clarify DESCRIPTION section Julia Evans via GitGitGadget
2025-08-19 20:46 ` [PATCH v3 1/3] Git 2.51 Junio C Hamano via GitGitGadget
2025-08-19 21:06 ` rsbecker
2025-08-19 21:37 ` Junio C Hamano
2025-08-19 21:44 ` D. Ben Knoble
2025-08-19 21:48 ` Julia Evans
2025-08-19 21:49 ` rsbecker
2025-08-19 20:46 ` [PATCH v3 2/3] doc: git-add: clarify intro & add an example Julia Evans via GitGitGadget
2025-08-21 20:08 ` Junio C Hamano
2025-08-22 20:37 ` Julia Evans
2025-08-19 20:46 ` [PATCH v3 3/3] doc: git-add: simplify discussion of ignored files Julia Evans via GitGitGadget
2025-08-21 20:09 ` Junio C Hamano
2025-08-29 11:55 ` [PATCH v4 0/2] doc: git-add: clarify DESCRIPTION section Julia Evans via GitGitGadget
2025-08-29 11:55 ` [PATCH v4 1/2] doc: git-add: clarify intro & add an example Julia Evans via GitGitGadget
2025-08-29 11:55 ` [PATCH v4 2/2] doc: git-add: simplify discussion of ignored files Julia Evans via GitGitGadget
2025-08-29 17:11 ` [PATCH v4 0/2] doc: git-add: clarify DESCRIPTION section Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqbjoks19f.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=julia@jvns.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).