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
Dec 5, 2012, 03:45 UTC
Message-ID
<CANiSa6iMxzQGM8mZYdfR-drPGgydwVpM5JsQ-8oO09MX5XDH+g@mail.gmail.com>
In-Reply-To
<7vd2yunn0e.fsf@alter.siamese.dyndns.org>
On Sat, Dec 1, 2012 at 1:24 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> Martin von Zweigbergk <martinvonz@gmail.com> writes:
>
>> On Thu, Nov 29, 2012 at 2:00 PM, Martin von Zweigbergk
>> <martinvonz@gmail.com> wrote:
>>> 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...
>
> "checkout $commit pathspec" has always been about ...

I suppose the "has always been" is meant to say that it's hard to change at this point, not that it's more intuitive the way it works..?

> ...checking out the
> contents stored in the paths that match the pathspec from the named
> commit to the index and also o the working tree.

I think I have always thought that "git checkout $commit $pathspec" would replace the section(s) of the tree defined by $pathspec. (I'm using "tree" in the more general sense here, as I'm understood the index is not stored as a tree.)

> When pathspec is "dir/", it does not match the directory whose name
> is "dir".  The pathspec matches the paths that store blobs under
> that directory.
Ah, right. Unlike "git reset dir/", IIUC.

More importantly, when is it desirable not to delete deleted entries? I find it much easier to imagine uses a "git checkout $commit $pathspec" that does delete deleted entries. It seems like this must have been discussed in depth before, so feel free to point me to an old thread.

If it doesn't seem too strange to you and others if I make "git reset --hard [$commit] $pathspec" work just like had expected "git checkout $commit $pathspec", I might look into that when I get some time.

> ...The "please
> remove everything in dir/" part is not the job of "checkout"; of
> course, you can do it as a separate step (e.g. "rm -fr dir/").

"rm -rf dir/" would of course delete everything in there, including e.g. build artifacts....

Previous: Junio C HamanoNext: Junio C Hamano
Message 15 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.