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

Re: Git reset --hard with staged changes

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 10, 2014, 05:44 UTC
Message-ID
<xmqqsindb9nu.fsf@gitster.dls.corp.google.com>
In-Reply-To
<loom.20140610T025754-449@post.gmane.org>
Dale Worley <worley@alum.mit.edu> writes:
> (As far as I can tell from Git's behavior, the definition of tracked file is
> "any file that is in the base commit or in the index".  Based on that
> definition, "git reset --hard" is working as documented.)

The book (whichever book you guys are talking about) is wrong, if it considers only the paths in the HEAD commit tracked. After the user deliberately does "git add" a path not in HEAD, the user runs any command (e.g. "git apply --index", "git cherry-pick --no-commit") that may bring a path not in HEAD to the result without recording a new commit that updates the HEAD, a new path is recorded in the index and that path is considered "tracked" before the resulting contents in the index is made into a commit.

Previous: Dale Worley
Message 9 of 9 in “Re: Git reset --hard with staged changes”
  1. Pierre-François CLEMENTJun 9, 2014
  2. David KastrupJun 9, 2014
  3. Pierre-François CLEMENTJun 9, 2014
  4. Junio C HamanoJun 9, 2014
  5. Pierre-François CLEMENTJun 10, 2014
  6. David KastrupJun 10, 2014
  7. Pierre-François CLEMENTJun 10, 2014
  8. Dale WorleyJun 10, 2014
  9. Junio C HamanoJun 10, 2014

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.