# User asks for a safety check on 'git reset --hard'; reviewers suggest other workflows

_After losing uncommitted work, Steven Rostedt asked for a confirmation config. Replies so far have suggested 'git restore' and branching habits, with caveats about untracked leftovers._

Section: Discussion. Edition of 2026-12-01. Written by an AI editor from the thread "Prevent git reset --hard from losing data" (10 messages): https://gitlist.dev/t/66901

Steven Rostedt wrote that he too often runs 'git reset --hard' in the wrong directory and loses uncommitted changes. He asked whether a configuration could check for uncommitted changes and ask for confirmation, and said he had just lost work this way.

D. Ben Knoble suggested a plain 'git restore .' and, being curious about Rostedt's habit of using reset to update a branch, proposed an alternative workflow: create a temporary branch from a useful base with 'git switch -c', do and commit the work, then merge it or cherry-pick it into the branch he cares about, editing the commit message as needed. Rostedt replied that he works on several topic branches at once, with development, for-next and urgent focuses, and switches among them while tests run for tens of minutes. He said he had not known about 'git restore'.

Junio C Hamano questioned whether an unstaged reset is a clean substitute. He said paths removed from the index, which the target commit did not have but the old index and working tree did, would remain as untracked files, and a later checkout back to the old state may refuse to overwrite them. He described having run 'git reset $another' by mistake when he wanted '--hard', and recovering with 'git reset @{1}' and then the hard reset.

Rostedt tried it on Linux kernel branches. After checking out v7.4-rc4, 'git reset v7.3.6' and 'git restore .', 'git status' still listed many files as untracked. Mirko Faina also took part. No one has proposed a patch, and the request for a confirmation config remains unanswered in the excerpts.
