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

Re: Why not git reset --hard <path>?

From
Jacob Keller <jacob.keller@gmail.com>
Date
Sep 29, 2015, 07:06 UTC
Message-ID
<CA+P7+xrzmDHyseGaJFkyUGUi=Uep0LLhPdZDeo3NeBBmXJTZWw@mail.gmail.com>
In-Reply-To
<xmqqvbaub5s4.fsf@gitster.mtv.corp.google.com>
On Mon, Sep 28, 2015 at 2:19 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> I agree with you if we limit the scope to "reset --hard" that does
> not mention any commit on the command line (or says "HEAD").
>
> However, for things like:
>
>     $ git reset --hard HEAD^ Makefile
>     $ git reset --hard HEAD@{4.hours.ago} Makefile
>
> I do not think "reset --hard" is a good match.  Conceptually, you
> are grabbing what was stored in a given commit and checking that out
> to your current workspace (that is, the index and the working tree).
>

Agreed. I just get used to thinking about using it against HEAD. it's just weird to me that something which sometimes switches branches is also the thing to grab a version of a file.

reset hard really would be weird in this case, because you really don't know if the user meant "rewind the history, but keep everything *except* that listed file..

That makes sense now that I think about it. Thanks.

Regards, Jake

Previous: Theodore Ts'oNext: George Spelvin
Message 6 of 11 in “Why not git reset --hard <path>?”
  1. George SpelvinSep 28, 2015
  2. Junio C HamanoSep 28, 2015
  3. Jacob KellerSep 28, 2015
  4. Junio C HamanoSep 28, 2015
  5. Theodore Ts'oSep 28, 2015
  6. Jacob KellerSep 29, 2015
  7. George SpelvinSep 29, 2015
  8. Philip OakleySep 29, 2015
  9. George SpelvinSep 28, 2015
  10. Junio C HamanoSep 28, 2015
  11. George SpelvinSep 28, 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.