git reset --keep HEAD~1

Category: Git - Advanced

git reset --keep HEAD~1

Reset while preserving local changes

Moves the branch back one commit but keeps working-tree and staged changes intact, aborting if they conflict with the reset. It is a safer middle ground between --mixed and --hard. Files touched only by the reset get updated.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.