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

Re: [PATCH v2] git-checkout.txt: Document "git checkout <pathspec>" better

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 17, 2015, 19:58 UTC
Message-ID
<xmqq8ubi6rap.fsf@gitster.dls.corp.google.com>
In-Reply-To
<5581CAA6.5080306@web.de>
Torsten Bögershausen <tboegi@web.de> writes:
Show 10 quoted lines
> On 2015-06-17 21.23, Junio C Hamano wrote:
> []
>>> Basically, I'm fine with anything starting with "Switch branches or",
>>> but please do change the headline ;-).
>> 
>> Likewise; I agree "switch branches or" part is good.
>
> How about this:
>
> git-checkout - Switch branches or restore changes to the working tree

Gahh. We are NOT restoring CHANGES. We are restoring the whole contents to a path.

It is perfectly fine to do this:
	git reset --hard
        git checkout HEAD^ hello.c
There is no changes in hello.c after "reset --hard".

This is what makes it tempting for me to say "check out (an existing contents to) a working tree file".

Moreover, it does not matter if the target file is changed or not in the first place, so your added text:

>> 'git checkout' with <paths> or `--patch` is used to restore modified or
>> deleted paths to their original contents from the index or replace paths
>> with the contents from a named <tree-ish> (most often a commit-ish).

that says "restoring modified or deleted is from the index, replacing is from a tree-ish" is placing a stress on a wrong spot, I would think.

"Checkout individual files" is to "replace contents with existing versions, taken either from the index or from a named tree-ish." That is done in preparation to come up with the suitable contents for specified paths.

This is a tangent, but on the other hand, "checkout a whole branch" is to prepare the working tree to be used to modify the specified branch. And that is why the word "checkout" makes sense for both operations.

Previous: Torsten BögershausenNext: Duy Nguyen
Message 17 of 20 in “git-checkout.txt: Document "git checkout <pathspec>" better”
  1. git-checkout.txt: Document "git checkout <pathspec>" betterTorsten Bögershausen, Jun 17, 2015
  2. Duy NguyenJun 17, 2015
  3. Matthieu MoyJun 17, 2015
  4. Andres G. AragonesesJun 17, 2015
  5. Matthieu MoyJun 17, 2015
  6. Andres G. AragonesesJun 17, 2015
  7. Matthieu MoyJun 17, 2015
  8. Junio C HamanoJun 17, 2015
  9. Torsten BögershausenJun 17, 2015
  10. Junio C HamanoJun 17, 2015
  11. Torsten BögershausenJun 17, 2015
  12. Matthieu MoyJun 17, 2015
  13. Andres G. AragonesesJun 17, 2015
  14. Junio C HamanoJun 17, 2015
  15. Junio C HamanoJun 17, 2015
  16. Torsten BögershausenJun 17, 2015
  17. Junio C HamanoJun 17, 2015
  18. Duy NguyenJun 18, 2015
  19. Junio C HamanoJun 18, 2015
  20. Matthieu MoyJun 18, 2015

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.