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

Re: What's cooking in git.git (Feb 2011, #06; Sun, 27)

From
Jeff King <peff@peff.net>
Date
Mar 2, 2011, 21:27 UTC
Message-ID
<20110302212724.GE20400@sigill.intra.peff.net>
In-Reply-To
<7vlj0yff6m.fsf@alter.siamese.dyndns.org>
On Tue, Mar 01, 2011 at 06:07:29PM -0800, Junio C Hamano wrote:
Show 20 quoted lines
> > On Mon, Feb 28, 2011 at 08:52:08AM -0800, Junio C Hamano wrote:
> >
> >> I am not convinced that this patch nailed that balance at exactly the
> >> right place, even though I think we are getting closer than before.  In
> >> this sequence:
> >> 
> >>     $ git checkout somewhere^0
> >>     $ git commit
> >>     $ git reset --hard somewhere_else
> >>     $ git commit
> >>     $ git checkout master
> >> ...
> > I really wouldn't expect it to help here. The problem isn't that you're
> > on a detached HEAD. It's that you're using "git reset" at all.
> 
> As you would realize later in your message, the "reset --hard" can instead
> be "checkout v1.7.3".  And the bothersome thing is that there is no safety
> against that.  We don't bother users while they are jumping around on
> detached HEAD, and it is not new; we don't say where the previous detached
> HEAD was.

No, "checkout v1.7.3" should engage the safety valve. And in your patch, it does. So replacing your reset --hard with checkout _is_ safe. And I think that behavior is reasonable. Reset's purpose is about shifting HEAD to drop history, whether you are on a detached HEAD or not. Having it warn would be annoying and pointless.

Checkout, on the other hand, is about moving your working tree to a different place in history, and we _should_ warn about dropping history. So it is really just a matter of educating users to use the appropriate tool for sight-seeing (and I don't think there is much education to be done; checkout seems like the obvious choice given it is how you got to the first commit).

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 12 in “What's cooking in git.git (Feb 2011, #06; Sun, 27)”
  1. Junio C HamanoFeb 28, 2011
  2. Sverre RabbelierFeb 28, 2011
  3. Junio C HamanoFeb 28, 2011
  4. Jeff KingMar 1, 2011
  5. Junio C HamanoMar 2, 2011
  6. Jeff KingMar 2, 2011
  7. Junio C HamanoMar 2, 2011
  8. Piotr KrukowieckiMar 2, 2011
  9. Jakub NarebskiMar 2, 2011
  10. Ævar Arnfjörð BjarmasonMar 10, 2011
  11. Jakub NarebskiMar 10, 2011
  12. Jeff KingMar 2, 2011

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.