git reset Move the branch back and optionally discard changes
Moves the current branch to another commit. Depending on the mode it also resets the staging area and your files. Use it to un-stage things or to undo local commits.
Synopsis
git reset [MODE] [COMMIT]
git reset [COMMIT] -- PATH...
Common options
| Option or form | What it does |
|---|---|
--soft | Move the branch only. Changes stay staged |
--mixed | The default. Move the branch and un-stage changes, but keep your files |
--hard | Move the branch and overwrite your files. Uncommitted work is lost |
HEAD~N | Go back N commits |
-- PATH | Un-stage a file without touching the branch |
Examples
git reset --soft HEAD~1
git reset HEAD~1
git reset HEAD -- app.js
git reset --hard origin/main
git reset --hard HEAD@{1}
Notes
- --hard deletes uncommitted work with no way back. Check git status and git stash first if unsure.
- Do not reset commits you have already pushed to a shared branch. Use git revert instead.
- git reflog lists earlier positions, so a committed state can usually be recovered.
See also
Last reviewed 2026-10-09.