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

Re: [PATCH 1/2] Documentation/git-checkout.txt: clarify usage

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 17, 2012, 19:12 UTC
Message-ID
<7vbodsmr1r.fsf@alter.siamese.dyndns.org>
In-Reply-To
<50CEDF0A.7040603@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> writes:
Show 21 quoted lines
> Am 12/17/2012 9:48, schrieb Junio C Hamano:
>> Here is what I tentatively have ...
>
> Thanks!
>
>> -'git checkout' [--detach] [<commit>]::
>> +'git checkout' --detach [<commit>]::
>> +'git checkout' <commit>::
>>  
>> -	Update the index and working tree to reflect the specified
>> -	commit and set HEAD to point directly to <commit> (see
>> -	"DETACHED HEAD" section.)  Passing `--detach` forces this
>> -	behavior even if <commit> is a branch.
>> +	Prepare to work on building new history on top of <commit>,
>> +	by detaching HEAD at the commit (see "DETACHED HEAD"
>> +	section), and updating the index and the files in the
>> +	working tree.  Local modifications to the files in the
>> +	working tree are kept, so that they can be committed on the
>> +	<branch>.
>
> The last half-sentence should better be removed.

True; we do not have a particular "on the <branch>" in this state. At least, "on the <branch>" needs to be removed. But I think we may want a more different wording here, including the earlier "work on building new history on top of" part.

The detached HEAD state primarily is a sightseeing mode, where the user is expected to view but not touch. Even for experienced users, commits on a detached HEAD are for keeping snapshots of interim states during a throw-away experiment, so the purpose of detaching is not exactly "to work on *building* new history" in the first place.

Carefree experimentation is encouraged by not forbidding commmits from this state, with the expectation that:

 (1) if it does not lead to interesting result, another "git
     checkout <branch>" will wipe the throw-away experiment without
     affecting any of your more important branches; and
 (2) an experiment that yielded something useful can be further
     polished on a concrete branch by "git checkout -b <newbranch>".

I think the above discussion on detached HEAD can be added to its own section.

	Prepare to work on top of <commit>, by detaching HEAD at it
	(see "DETACHED HEAD" section), and updating te index and the
	files in the working tree.  Local modifications to the files
	in the working tree are kept, so that the resulting working
	tree will be the state recorded in the commit plus the local
	modifications.
Or something, perhaps?
Previous: Johannes SixtNext: Andrew Ardill
Message 7 of 23 in “Documentation: clarify usage of checkout”
  1. 0/2 Documentation: clarify usage of checkoutChris Rorvick, Dec 17, 2012
  2. 1/2 Documentation/git-checkout.txt: clarify usageChris Rorvick, Dec 17, 2012
  3. Junio C HamanoDec 17, 2012
  4. Johannes SixtDec 17, 2012
  5. Junio C HamanoDec 17, 2012
  6. Johannes SixtDec 17, 2012
  7. Junio C HamanoDec 17, 2012
  8. Andrew ArdillDec 17, 2012
  9. Chris RorvickDec 18, 2012
  10. Philip OakleyDec 17, 2012
  11. Junio C HamanoDec 17, 2012
  12. Andrew ArdillDec 17, 2012
  13. Junio C HamanoDec 17, 2012
  14. Andrew ArdillDec 18, 2012
  15. Junio C HamanoDec 18, 2012
  16. Andrew ArdillDec 18, 2012
  17. Chris RorvickDec 18, 2012
  18. Junio C HamanoDec 18, 2012
  19. Philip OakleyDec 17, 2012
  20. 2/2 Documentation/git-checkout.txt: document 70c9ac2 behaviorChris Rorvick, Dec 17, 2012
  21. Junio C HamanoDec 17, 2012
  22. Andrew ArdillDec 17, 2012
  23. Junio C HamanoDec 17, 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.