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 formWhat it does
--softMove the branch only. Changes stay staged
--mixedThe default. Move the branch and un-stage changes, but keep your files
--hardMove the branch and overwrite your files. Uncommitted work is lost
HEAD~NGo back N commits
-- PATHUn-stage a file without touching the branch

Examples

Undo the last commit but keep the work staged
git reset --soft HEAD~1
Undo the last commit and un-stage the changes
git reset HEAD~1
Un-stage one file
git reset HEAD -- app.js
Throw away everything and match a commit
git reset --hard origin/main
Get back after a mistake
git reset --hard HEAD@{1}

Notes

See also

Last reviewed 2026-10-09.