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

Re: [PATCH] Detached HEAD (experimental)

From
Andreas Ericsson <ae@op5.se>
Date
Jan 11, 2007, 09:45 UTC
Message-ID
<45A60736.4050503@op5.se>
In-Reply-To
<Pine.LNX.4.64.0701101041210.20138@iabervon.org>
Daniel Barkalow wrote:
Show 34 quoted lines
> On Wed, 10 Jan 2007, Junio C Hamano wrote:
> 
>> Andreas Ericsson <ae@op5.se> writes:
>>
>>> ... Since committing on
>>> detached heads really should be a very rare case I don't think many
>>> people will find this terribly annoying.
>> Quite the contrary, I would imagine it would be quite natural to
>> do throw-away commits and merges on detached head while
>> bisecting the history (e.g. commit small fixup to make it
>> compile and then mark the result for bisection to hunt for real
>> bugs that are hidden by silly compilation problems).  
> 
> I don't think this would actually work. If you commit your build fix, and 
> then mark the result as bad, won't bisect skew its choices due to 
> suspecting that your build fix is the real bug?
> 
> I'd think that, if you make changes while bisecting, you probably want to 
> leave those changes uncommitted, and merge or discard them when testing 
> other commits.
> 
> If anything, I'd think you'd want a rather different sort of commit 
> mechanism than the usual commit, which says, "whenever you consider commit 
> {sha1-from-real-history}, use {tree-with-local-changes} instead of 
> {tree-in-real-commit}." Or, more generally, "in order to get the trees 
> I want to actually use, this patch (git diff HEAD) needs to be applied to 
> every commit in some portion of the history including, at least, 
> get_sha1(HEAD)".
> 
> I'm not seeing any actual benefit to causing the history to contain a 
> dead-end fork off of an antique commit, and then throwing this away. And 
> committing your change so that it won't get lost, with the intention of 
> losing it in a little while, doesn't seem to make any sense, either.
> 

Same here. I'd imagine temporary build-fixes to live as a patch-file generated by

	git diff > build-fixes.diff

after having hacked on the tree. There's no sane way of inserting commits into the middle of the DAG, so committing on something that isn't a branch with the intention of losing it is just plain weird.

> (Of course, it also makes sense to do merges, but again, you probably want 
> to create and temporarily use the working tree resulting from the merge, 
> not create the commit.)
> 

Yes. I'd imagine "git merge --no-commit" could be used for this, to merge things only in the working directory.

Show 5 quoted lines
> I think that the workflow that uses regular commits with a detached HEAD 
> is this: do a series of commits representing real work on top of a remote 
> branch or a tag, and decide later (once you've tested the results for 
> worthiness) whether to turn this into a topic branch or throw it away.
> 

Perhaps, but this is also a bit weird, as you would normally hack things up to fit on top of some already existing branch, so then you'd detach the head but point it to something that already has a branch-name associated with it.

Otoh, I could imagine this would be sort of nifty for applying bugfixes on top of old tags, so perhaps it's not so weird after all. Then you'd probably want to create a new tag before releasing the bugfixed version, so Linus suggestion makes sense in this case (assuming it doesn't fsck up the bisect case, ofc).

Show 7 quoted lines
> But I don't think this is a good match for detached HEAD, because you may 
> want to do exactly the same thing, but start with a regular local head. I 
> think the right thing to do is something like "git checkout --anon", which 
> puts you on a new branch with no name, which will evaporate if you leave 
> it (as per "git branch -d"; you need to force it if it isn't fully 
> merged).
> 

Yes. I'd imagine "git merge --no-commit" could be used for this, to merge things only in the working directory. We could easily create a hack for this by doing a "git reset --mixed HEAD^1" after the merge is complete.

Show 5 quoted lines
> So I think the feature which lets you make commits without being on a 
> branch from refs/heads is actually a different feature from "detached 
> HEAD", which only shares the aspect that "git branch" has no line with a 
> "*", because there is no name for what HEAD points to.
> 

Agreed. They really are two completely different things. I see no harm in splitting them up codewise. Bisect could start working without its protected branch straight away, but commits (and merges) to detached heads wouldn't work at all. Then we can see what use people put this to and what walls they run into and make the feature accordingly.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Previous: Daniel BarkalowNext: Junio C Hamano
Message 41 of 68 in “Detached HEAD (experimental)”
  1. Detached HEAD (experimental)Junio C Hamano, Jan 2, 2007
  2. Edgar ToernigJan 2, 2007
  3. Carl WorthJan 2, 2007
  4. Jakub NarebskiJan 2, 2007
  5. Carl WorthJan 3, 2007
  6. J. Bruce FieldsJan 6, 2007
  7. Alan ChandlerJan 6, 2007
  8. J. Bruce FieldsJan 6, 2007
  9. Junio C HamanoJan 2, 2007
  10. Carl WorthJan 2, 2007
  11. Junio C HamanoJan 3, 2007
  12. Junio C HamanoJan 8, 2007
  13. Jeff KingJan 8, 2007
  14. Junio C HamanoJan 9, 2007
  15. Carl WorthJan 9, 2007
  16. Junio C HamanoJan 9, 2007
  17. Carl WorthJan 9, 2007
  18. Shawn O. PearceJan 9, 2007
  19. Junio C HamanoJan 9, 2007
  20. 0/6 Expose in_merge_bases() via merge-base.Junio C Hamano, Jan 9, 2007
  21. Luben TuikovJan 9, 2007
  22. Jeff KingJan 9, 2007
  23. Junio C HamanoJan 9, 2007
  24. J. Bruce FieldsJan 9, 2007
  25. Carl WorthJan 9, 2007
  26. J. Bruce FieldsJan 9, 2007
  27. Shawn O. PearceJan 9, 2007
  28. Jakub NarebskiJan 10, 2007
  29. Shawn O. PearceJan 10, 2007
  30. J. Bruce FieldsJan 10, 2007
  31. Shawn O. PearceJan 10, 2007
  32. Nicolas PitreJan 10, 2007
  33. Junio C HamanoJan 10, 2007
  34. Shawn O. PearceJan 10, 2007
  35. Nicolas PitreJan 10, 2007
  36. Shawn O. PearceJan 10, 2007
  37. Jakub NarebskiJan 10, 2007
  38. Andreas EricssonJan 10, 2007
  39. Junio C HamanoJan 10, 2007
  40. Daniel BarkalowJan 10, 2007
  41. Andreas EricssonJan 11, 2007
  42. Junio C HamanoJan 10, 2007
  43. Junio C HamanoJan 9, 2007
  44. Shawn O. PearceJan 9, 2007
  45. Linus TorvaldsJan 9, 2007
  46. Junio C HamanoJan 10, 2007
  47. Shawn O. PearceJan 10, 2007
  48. Linus TorvaldsJan 10, 2007
  49. Carl WorthJan 10, 2007
  50. Junio C HamanoJan 10, 2007
  51. Andy ParkinsJan 10, 2007
  52. Shawn O. PearceJan 10, 2007
  53. Junio C HamanoJan 10, 2007
  54. Andy ParkinsJan 10, 2007
  55. Shawn O. PearceJan 10, 2007
  56. Junio C HamanoJan 10, 2007
  57. Jeff KingJan 10, 2007
  58. Junio C HamanoJan 11, 2007
  59. J. Bruce FieldsJan 11, 2007
  60. Jeff KingJan 3, 2007
  61. Jeff KingJan 3, 2007
  62. git-branch: show detached HEADLars Hjemli, Jan 2, 2007
  63. Shawn O. PearceJan 3, 2007
  64. Junio C HamanoJan 3, 2007
  65. Lars HjemliJan 3, 2007
  66. Junio C HamanoJan 3, 2007
  67. Junio C HamanoJan 3, 2007
  68. Lars HjemliJan 3, 2007

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.