All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Adam T via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, "Elijah Newren" <newren@gmail.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Adam T" <admr0805@gmail.com>
Subject: Re: [PATCH 0/2] rm: revisiting --staged and --worktree
Date: Sun, 06 Dec 2026 09:37:08 +0900	[thread overview]
Message-ID: <xmqqecbvi6rv.fsf@gitster.g> (raw)
In-Reply-To: <pull.2349.git.1796455144.gitgitgadget@gmail.com> (Adam T. via GitGitGadget's message of "Sat, 05 Dec 2026 07:19:02 +0000")

"Adam T  via GitGitGadget" <gitgitgadget@gmail.com> writes:

>     While this series only introduces the feature for rm, I generally agree
>     with this. It makes --worktree and --staged the standard, which reduces
>     the friction you'd expect while using Git.

I am not sure what "friction" this reduces; adding more option names for
the same thing may only add confusion.  As described in the gitcli
manual, '--cached' is about affecting only the index, and 'rm --cached'
is exactly that.

We should not deprecate '--cached' or '--index'.  They are short and
easy to type, and users' fingers have been trained to use them for over
20 years.  However, I have no fundamental objection to introducing
'--index-only' as an alias for 'rm --cached'.

It would be more to type, but its meaning would be more obvious to
anybody who understands how the user builds up the next commit in the
index alongside the working tree files, and how the difference between
the two allows the user to make progress.  While 'rm --cached' tells you
that it affects the index, '--index-only' improves on it by making it
clear that the index is the _only_ thing it touches.

Note that 'rm --staged' does not improve over 'rm --cached' on that
front.

For the default operation, lack of any option is sufficient, and the
usual "last one wins" rule can be used to override an earlier option.

    $ git rm --index-only --no-index-only foo

may start with "I want to remove only from the index" and then
countermand it with "nono, I do not want that only-from-the-index mode
in effect".  This already works with '--cached' and '--no-cached' to go
back to the default behavior of removing the paths from both the index
and the working tree, so a separate '--index-and-working-tree' synonym
may not even be needed, even though it would help those who do not yet
know by default 'git rm' removes from both the index and the working
tree (in other words, it would be a helpful addition only for the first
two weeks of a new user's Git experience, until these users (1) stop
using Git migrating to another system, (2) stop using the option,
quickly learning that it is the default and forget about it, or (3) keep
using the option, wasting time and keystrokes every time they want to
remove tracked paths).

In general, I am mildly opposed to aliases that are not really needed,
as they tend to proliferate and fracture the learning experience.  If we
do adopt '--index-only', all subcommands that take '--cached' to operate
only on the index ('apply', 'check-ignore', 'ls-files', etc.) should
learn it for consistency, not just 'rm'.

Also, please be careful when mentioning "worktree" and "working tree",
as they are two distinct concepts.  In this case, it is also doubtful
that 'git rm --working-tree-only' is needed, since it is unclear what it
does differently from regular 'rm'.

Hope this helps establish the design perimeter better.

Thanks.

---
 builtin/rm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git c/builtin/rm.c w/builtin/rm.c
index 081d0bc375..5804b00c0b 100644
--- c/builtin/rm.c
+++ w/builtin/rm.c
@@ -252,6 +252,7 @@ static struct option builtin_rm_options[] = {
 	OPT__DRY_RUN(&show_only, N_("dry run")),
 	OPT__QUIET(&quiet, N_("do not list removed files")),
 	OPT_BOOL( 0 , "cached",         &index_only, N_("only remove from the index")),
+	OPT_ALIAS(0, "index-only", "cached"),
 	OPT__FORCE(&force, N_("override the up-to-date check"), PARSE_OPT_NOCOMPLETE),
 	OPT_BOOL('r', NULL,             &recursive,  N_("allow recursive removal")),
 	OPT_BOOL( 0 , "ignore-unmatch", &ignore_unmatch,

      parent reply	other threads:[~2026-12-06  0:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  7:19 [PATCH 0/2] rm: revisiting --staged and --worktree Adam T  via GitGitGadget
2026-12-05  7:19 ` [PATCH 1/2] rm: add " adam torres encarnacion via GitGitGadget
2026-12-05 15:15   ` D. Ben Knoble
2026-12-05 16:32     ` Adam
2026-12-05  7:19 ` [PATCH 2/2] rm: relax --worktree-only restrictions adam torres encarnacion via GitGitGadget
2026-12-05 15:15 ` [PATCH 0/2] rm: revisiting --staged and --worktree D. Ben Knoble
2026-12-05 16:32   ` Adam
2026-12-06  0:37 ` Junio C Hamano [this message]

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=xmqqecbvi6rv.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=admr0805@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=newren@gmail.com \
    --cc=pclouds@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.