git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Julia Evans" <julia@jvns.ca>
Cc: "Julia Evans" <gitgitgadget@gmail.com>,  git@vger.kernel.org
Subject: Re: [PATCH 3/4] doc: git-reset: clarify `git reset [mode]`
Date: Mon, 20 Oct 2025 13:44:50 -0700	[thread overview]
Message-ID: <xmqqcy6hz4jh.fsf@gitster.g> (raw)
In-Reply-To: <a6d94c76-c9fe-4688-8eea-3bbab2b5dc07@app.fastmail.com> (Julia Evans's message of "Mon, 20 Oct 2025 16:23:44 -0400")

"Julia Evans" <julia@jvns.ca> writes:

> On Sat, Oct 18, 2025, at 12:53 AM, Junio C Hamano wrote:
>> "Julia Evans via GitGitGadget" <gitgitgadget@gmail.com> writes:
>>
>>> +`--soft`::
>>> +	Leaves your working directory unchanged. The index is left unchanged,
>>
>> Why not "leave your working tree files and the index unchanged"?
>
> The reason I say "working directory" instead of "working tree" is that
> I've seen a few comments from users saying that they don't know
> what "working tree" means. I'm still not sure what the reason for
> calling it a "working tree" is.

"working tree" refers to the directory that is the top level of a
checkout; I'd view (current) "working directory" can be anything
$(pwd), that may be outside control of any git repository, and that
is why I tend to avoid the latter when I want to be more precise
(and "worktree" is another thing---used to refer to one particular
"working tree" among other working trees attached to the same
repository).

But that distinction was not the part I wanted to comment on.  The
question was about two sentences talking about two things
separately.  IOW

	Leave your working directory and the index unchanged.

is what I would have expected, and I was wondering why they are
treated separately.  After all, the index is part of your working
tree state.

> The reason for keeping them separate sentences is just for symmetry with
> the other commands, and also because (like I mentioned in the commit
> message) "leaving X and Y unchanged" makes it sound like leaving X and
> Y unchanged is a "neutral operation", while actually leaving the index
> unchanged while updating HEAD is actually a fairly weird thing to do.

Sorry, but I do not understand this comment.

The index and the HEAD are two different things, and it is natural
that they can move independently.  After all we update the former
without updating the latter all the time (it is called "git add").

Besides, the two things the --soft does not touch are the files in
the working tree and the index.  The index has what you want to make
the next commit out of, and the working tree has the state that may
come after that state in the index.  Keeping both of them intact
when moving HEAD around is one natural thing to do when you want to
squash the previous N commits after "git add <paths>" by doing "git
reset --soft HEAD~N && git commit".  Contrasting to that, "--mixed"
would leave the files in the working tree intact, while matching the
index to the HEAD you are moving to, essentially undoing your "git
add"s before you decided to reset.  That's another natural thing to
do when you decide to keep the clean slate and rebuild your index from
scratch to prepare for a commit that comes on top of the commit you
are moving to.

So, no, I do not understand the above comment.

> Do you mean `git reset` and `git cherry-pick`, or are there other operations
> that can leave the operation in an unmerged state?

There are many commands that leaves the index unmerged, like "am
-3", "rebase", "switch -m", "stash pop", etc.


  parent reply	other threads:[~2025-10-20 20:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-17 20:05 [PATCH 0/4] doc: git-reset: clarify DESCRIPTION section Julia Evans via GitGitGadget
2025-10-17 20:05 ` [PATCH 1/4] doc: git-reset: reorder the forms Julia Evans via GitGitGadget
2025-10-17 22:20   ` Junio C Hamano
2025-10-20 19:03     ` Julia Evans
2025-10-17 20:05 ` [PATCH 2/4] doc: git-reset: clarify intro Julia Evans via GitGitGadget
2025-10-17 22:32   ` Junio C Hamano
2025-10-20 19:29     ` Julia Evans
2025-10-20 20:00       ` Junio C Hamano
2025-10-20 20:30         ` D. Ben Knoble
2025-12-03 18:15       ` Julia Evans
2025-10-17 20:05 ` [PATCH 3/4] doc: git-reset: clarify `git reset [mode]` Julia Evans via GitGitGadget
2025-10-18  4:53   ` Junio C Hamano
2025-10-20 20:23     ` Julia Evans
2025-10-20 20:33       ` D. Ben Knoble
2025-10-20 20:44       ` Junio C Hamano [this message]
2025-10-17 20:05 ` [PATCH 4/4] doc: git-reset: clarify `git reset <pathspec>` Julia Evans via GitGitGadget
2025-10-17 23:25   ` Junio C Hamano
2025-10-18 14:06     ` Ben Knoble
2025-10-18 16:17       ` Junio C Hamano
2025-12-19  0:23 ` [PATCH v2 0/4] doc: git-reset: clarify DESCRIPTION section D. Ben Knoble
2025-12-19  0:23   ` [PATCH v2 1/4] doc: git-reset: reorder the forms D. Ben Knoble
2025-12-19  0:23   ` [PATCH v2 2/4] doc: git-reset: clarify intro D. Ben Knoble
2025-12-19  0:23   ` [PATCH v2 3/4] doc: git-reset: clarify `git reset [mode]` D. Ben Knoble
2025-12-19  0:23   ` [PATCH v2 4/4] doc: git-reset: clarify `git reset <pathspec>` D. Ben Knoble
2025-12-30  5:23     ` 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=xmqqcy6hz4jh.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).