git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Proposal: "unadd" command / alias.

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 28, 2020, 23:44 UTC
Message-ID
<xmqqmu059arb.fsf@gitster.c.googlers.com>
In-Reply-To
<CAAdniQ5pRHKUU77XVmZkZ_gUgfYYFpo9=Xt2T6EgzJ3hoT0YMg@mail.gmail.com>
Filipp Bakanov <filipp@bakanov.su> writes:
Show 11 quoted lines
> Hi! I suggest to add "unadd" command, that will undo a git add command.
>
> git unadd path/to/file
>
> It will be an alias to:
>
> git reset HEAD -- path/to/file
>
> The motivation is that I always forget syntax and have to google each
> time I want to undo accidentally added files. Unadd is just much
> easier to remember and quite obvious.

I am not sure if the behaviour of the "git reset HEAD -- path" is what people would imagine what "unadd" would do, actually. For example, with this sequence:

    $ edit file
    $ git add file
    $ edit file
    $ git add file
    $ git unadd file

what would be the natural expectation of users after the last "unadd" step? Should it have the result of the first 'add'? Should another "git unadd file" bring the index back to the state before the first 'add' was run?

There is no such ambiguity to "reset HEAD -- path". It tells exactly what contents you want to have in the index for the path (i.e. the same as what is in HEAD). There is no "go back to the state before the last add", and there is no false hint that such a thing might exist.

So, I do not think it is a good idea to even call it "unadd", let alone adding an alias that is used outside your immediate circle where you can explain what it exactly means to "unadd" by your definition.

Previous: Filipp BakanovNext: Konstantin Tokarev
Message 10 of 12 in “Proposal: "unadd" command / alias.”
  1. Filipp BakanovOct 27, 2020
  2. Junio C HamanoOct 27, 2020
  3. Theodore Y. Ts'oOct 27, 2020
  4. Filipp BakanovOct 27, 2020
  5. Theodore Y. Ts'oOct 27, 2020
  6. Filipp BakanovOct 27, 2020
  7. Philip OakleyOct 28, 2020
  8. Pratyush YadavOct 28, 2020
  9. Filipp BakanovOct 28, 2020
  10. Junio C HamanoOct 28, 2020
  11. Konstantin TokarevOct 28, 2020
  12. Filipp BakanovOct 28, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.