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

Re: Reset by checkout?

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 2, 2014, 21:54 UTC
Message-ID
<xmqqmwdv2d08.fsf@gitster.dls.corp.google.com>
In-Reply-To
<538AE814.2010407@bracey.fi>
Kevin Bracey <kevin@bracey.fi> writes:
> Maybe something like this:

I like the overall direction to re-organize the description by operations, but the new description seem to introduce a bit of new confusion.

Show 9 quoted lines
> "All modes move the current branch pointer so that HEAD now points to
> the specified commit. ORIG_HEAD is set to the original HEAD
> location. The modes differ in what happens to the contents of
> ORIG_HEAD, that are no longer on the reset branch; and also what
> happens to your not-yet-committed changes.
>
> --soft
>      Retains the contents of ORIG_HEAD in the index+work area,
> leaving the difference as "changes to be committed".

This (and everything that talks about ORIG_HEAD) asks the user to think of the working tree state as a combination of "the state the commit you were on represents" plus "the changes you made relative to it".

Given that everything Git records is a whole-tree snapshot, "state" (not "changes"), and that is how tutorials teach Git, I wonder if the "what is done to ORIG_HEAD and changes" gets the user into right mindset to understand various modes of operations.

And with that "ORIG_HEAD and changes" mindset, a --soft reset becomes very hard to explain. "ORIG_HEAD and changes (you had before you issued the 'reset --soft' command)" are left in the index/work, "HEAD" becomes the named commit, "changes from that updated HEAD" becomes the original changes (you had since ORIG_HEAD) mixed with the differences between ORIG_HEAD and HEAD.

If you explain this in terms of "state", a --soft reset will keep the state of the index and the working tree as-is and changes the HEAD pointer to point at a different commit.

Show 9 quoted lines
> "git reset --soft HEAD~1"
> would be the first step if you want to remove the last commit, but
> intend to recommit most or all of its changes.
>
> "git status" after reset --soft shows:
>
>   To be committed:
>        Changes in ORIG_HEAD relative to HEAD
>        (+Any initial staged changes)

There would be overlapping parts of "Any initial staged changes" and "Changes in ORIG_HEAD relative to HEAD". They may be mixed, they may be partly reverted, or they may totally cancel out, depending on the changes the user made since starting to work on ORIG_HEAD.

Show 6 quoted lines
>   Not staged:
>        (Any initial unstaged changes)
>
> --mixed (default)
>     Retains the contents of ORIG_HEAD in the work area, leaving the
> difference as unstaged changes.

I am confused by the above the same way. If the operation "retains the contents of ORIG_HEAD" in the working tree, would that mean the edit I made is somehow reverted? No, because you say "leaving the difference ...", but then the operation is not really retaining the contents of ORIG_HEAD. It is leaving the state I had in my working tree as-is, regardless of ORIG_HEAD and/or HEAD that is updated.

Not that I can think of a better way to update these descriptions, and not that I am opposing to update these descriptions to make it easier for new people to learn, but I am not sure if these "treat ORIG_HEAD and the changes since that commit as separate entities" is a good approach to do so.

Somewhat frustrated, not by your patch but by being unable to suggest a better way X-<.

Previous: Kevin BraceyNext: Kevin Bracey
Message 7 of 18 in “Reset by checkout?”
  1. Atsushi NakagawaMay 31, 2014
  2. Andreas SchwabMay 31, 2014
  3. Atsushi NakagawaJun 1, 2014
  4. Kevin BraceyMay 31, 2014
  5. Atsushi NakagawaJun 1, 2014
  6. Kevin BraceyJun 1, 2014
  7. Junio C HamanoJun 2, 2014
  8. Kevin BraceyJun 3, 2014
  9. Felipe ContrerasJun 3, 2014
  10. Atsushi NakagawaJun 7, 2014
  11. Philip OakleyJun 7, 2014
  12. Kevin BraceyJun 9, 2014
  13. Atsushi NakagawaJun 7, 2014
  14. Felipe ContrerasMay 31, 2014
  15. Felipe ContrerasMay 31, 2014
  16. Atsushi NakagawaJun 1, 2014
  17. Junio C HamanoJun 2, 2014
  18. Junio C HamanoJun 2, 2014

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.