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

Re: Git reset --hard with staged changes

From
David Kastrup <dak@gnu.org>
Date
Jun 9, 2014, 14:04 UTC
Message-ID
<87vbsayy9w.fsf@fencepost.gnu.org>
In-Reply-To
<CANWD=rX-MEiS4cNzDWr2wwkshz2zu8-L31UrKwbZrJSBcJX-nQ@mail.gmail.com>
Pierre-François CLEMENT <likeyn@gmail.com> writes:
Show 13 quoted lines
> Hi all,
>
> Someone pointed out on the "Git for human beings" Google group
> (https://groups.google.com/d/topic/git-users/27_FxIV_100/discussion)
> that using git-reset's hard mode when having staged untracked files
> simply deletes them from the working dir.
>
> Since git-reset specifically doesn't touch untracked files, one could
> expect having staged untracked files reset to their previous
> "untracked" state rather than being deleted.
>
> Could this be a bug or a missing feature? Or if it isn't, can someone
> explain what we got wrong?
git reset --keep maybe?
In a work dir and index without modifications, I expect

git apply --index ... git reset --hard

to remove any files that git apply created. It would not do so using your proposal. I agree that it seems a bit of a borderline, but I consider it better that once a file _is_ tracked, git reset --hard will first physically remove it before untracking it.

-- 
David Kastrup
Previous: Pierre-François CLEMENTNext: Pierre-François CLEMENT
Message 2 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.