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

Re: Git reset --hard with staged changes

From
Junio C Hamano <gitster@pobox.com>
Date
May 23, 2016, 21:16 UTC
Message-ID
<xmqqeg8s8og8.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAP8UFD0dQGmfhPuHjEGRZjEZHwUHR_XzAASwq+87Obf26yi+BQ@mail.gmail.com>
Christian Couder <christian.couder@gmail.com> writes:
Show 7 quoted lines
>> This should be clarified to define what a tracked file is. I propose appending:
>>
>>     A file is considered tracked if it exists in a prior commit or in the
>>     staging area. Note that a newly added file not in any prior commit will be
>>     removed.
>
> Would you like to send a patch with something like the above?
I am not sure if that is a good addition, though.
> I don't know if something about why it is like this, or why it is the
> right thing to do, at least for recovering from merges, should be
> added though.
I excuse you as it seems that you haven't read my response ;-)
>> I would also like to propose that the staging area's tree object be saved,
>> ..
> Yeah, it might be a good idea.
Two issues with that "proposal" is that
 1. the index may not be writable as a tree (think: during a
    conflict resolution); and
 2. the sole point of "reset --hard" is to "discard the changes".
    If you want to instead save them away, there is another command
    that was designed to do just that.

It wasn't all that surprising that those on stackoverflow would think such a proposal is a good idea, but I somehow was hoping you have been around here long enough to know "git stash" ;-)

Previous: Christian CouderNext: Christian Couder
Message 4 of 8 in “Re: Git reset --hard with staged changes”
  1. Yotam GingoldMay 23, 2016
  2. Junio C HamanoMay 23, 2016
  3. Christian CouderMay 23, 2016
  4. Junio C HamanoMay 23, 2016
  5. Christian CouderMay 24, 2016
  6. Yotam GingoldMay 30, 2016
  7. Junio C HamanoMay 31, 2016
  8. Christian CouderMay 31, 2016

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.