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

git reset --hard and uncommitted files in index

From
TGThomas Guyot-Sionnest <dermoth@aei.ca>
Date
May 22, 2009, 02:32 UTC
Message-ID
<gv52s4$e7h$1@ger.gmane.org>
Hi,

Today I was working on a script that modify many files on a repository, therefore during testing phase I needed to reset --hard to get back to the last commit. This operation does not affect untracked files.

Since i was going to commit the script, at some point I decided to add it to the index so I could track/revert changes to it. On the next reset Git deleted the script.

Fortunately "git add" creates an object that I could easily recover (thanks to wereHamster on #git for pointing that out), however I was wondering if it's really the desired behavior to *delete* a file that have been added to the index but isn't on the previous commit? Shouldn't git just unstage it?

-- Thomas

Next: Johannes Sixt
Message 1 of 3 in “git reset --hard and uncommitted files in index”
  1. Thomas Guyot-SionnestMay 22, 2009
  2. Johannes SixtMay 22, 2009
  3. Sverre RabbelierMay 22, 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.