Subject: Re: Proposal: "unadd" command / alias.

From: Junio C Hamano <[email-masked]>
Date: Wed, 28 Oct 2020 16:44:08 -0700

Filipp Bakanov <[email-masked]> writes:

> 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.