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

Re: [RFC/PATCH 1/2] reset: learn to reset to tree

From
Martin von Zweigbergk <martinvonz@gmail.com>
Date
Nov 29, 2012, 22:00 UTC
Message-ID
<CANiSa6hWYsfm0t+s_q7=CcD78yNfpuduxkRc35xW8qDOy97W3g@mail.gmail.com>
In-Reply-To
<7vzk20p6ik.fsf@alter.siamese.dyndns.org>
On Thu, Nov 29, 2012 at 11:13 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 6 quoted lines
> [...]These
> two commands, "reset" and "checkout", share that the source we grab
> the blobs out of only need to be a tree and does not have to be a
> commit, and the only difference between them is where the blobs we
> grabbed out of that tree go, either only to the index or to both the
> index and the working tree.

Slightly off topic, but another difference (or somehow another aspect of the same difference?) that has tripped me up a few times is that "git checkout $rev ." only affects added and modified files (in $rev compared to HEAD), but "git reset $rev ." would also delete deleted files from the index. I suppose this is also a partial answer to your question in another message:

> What does it even mean, even when you are on an existing commit, to
> hard reset partially?
>
> Perhaps you looking for "git checkout $tree -- $path"?

A more direct answer would be that I would expect "git reset --hard $rev -- ." to behave like "git reset --hard $rev", except that it wouldn't update HEAD. It seems to me that that would be similar to how "git reset $rev -- ." behaves like "git reset $rev", except that it doesn't update HEAD. But reset and checkout with and without paths still confuse me after years of using git, so I wouldn't be surprised if I'm not making any sense.

Previous: Junio C HamanoNext: Martin von Zweigbergk
Message 12 of 18 in “Operations on unborn branch”
  1. Martin von ZweigbergkNov 27, 2012
  2. Junio C HamanoNov 27, 2012
  3. Martin von ZweigbergkNov 27, 2012
  4. Junio C HamanoNov 28, 2012
  5. Martin von ZweigbergkNov 30, 2012
  6. 0/2 Fix "git reset" on unborn branchMartin von Zweigbergk, Nov 29, 2012
  7. 1/2 reset: learn to reset to treeMartin von Zweigbergk, Nov 29, 2012
  8. Junio C HamanoNov 29, 2012
  9. Martin von ZweigbergkNov 29, 2012
  10. Junio C HamanoNov 29, 2012
  11. Junio C HamanoNov 29, 2012
  12. Martin von ZweigbergkNov 29, 2012
  13. Martin von ZweigbergkNov 30, 2012
  14. Junio C HamanoDec 1, 2012
  15. Martin von ZweigbergkDec 5, 2012
  16. Junio C HamanoDec 5, 2012
  17. Martin von ZweigbergkDec 5, 2012
  18. 2/2 reset: learn to reset on unborn branchMartin von Zweigbergk, Nov 29, 2012

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.