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

Re: "git reset --hard" == "git checkout HEAD" == "git reset --hard HEAD" ???

From
Sitaram Chamarty <sitaramc@gmail.com>
Date
Jan 3, 2009, 12:27 UTC
Message-ID
<slrnglumdd.erd.sitaramc@sitaramc.homelinux.net>
In-Reply-To
<7vprj4ae5y.fsf@gitster.siamese.dyndns.org>
On 2009-01-03, Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
> Sitaram Chamarty <sitaramc@gmail.com> writes:
>
>>>> It seems we have 2 ways to blow away work we haven't
>>>> checked in yet then right?
>>>
>>> Wrong.
>>
>> Strictly as asked, yes, but what if he adds a "-f" to the
>> middle command, making it "git checkout -f HEAD"?  Wouldn't
>> that be the same as the others then?
>
> Yeah, but comparing reset and checkout misses a whole _dimension_ in the
> revision space continuum.
[snip]
> "checkout -f" and "reset --hard" work on different dimensions, and what
> they do intersect when (and only when) the <branch>/<commit> argument
> happen to be HEAD.  "checkout -f <another>" and "reset --hard <another>"
> will do quite different things.

I teach git sometimes (internally) in my job. It seems to me that people who don't like TMTOWTDI get stuck on this "why are there 2 ways to do the same thing" aspect, even after I explain all the *other* uses of the two commands to show that they're actually quite different!

Your use of "dimension" and "degenerate case" gave me an idea... most of my audience have decent math skills, so I bet they get it if I say these are like two quite different functions that just happen to intersect at x=0 :-)

Thank you very much!
Previous: Junio C Hamano
Message 5 of 5 in “"git reset --hard" == "git checkout HEAD" == "git reset --hard HEAD" ???”
  1. chris@seberino.orgJan 2, 2009
  2. Junio C HamanoJan 2, 2009
  3. Sitaram ChamartyJan 3, 2009
  4. Junio C HamanoJan 3, 2009
  5. Sitaram ChamartyJan 3, 2009

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.