git reset: soft, mixed and hard
The three modes move the branch back the same way and differ only in what they do with your work.
The same starting point, three results
We made a repository with two commits. Before each reset we also had an unsaved edit to notes.txt and a new file draft.txt that had been added to the staging area. Then we ran each mode with HEAD~1 (one commit back). This is what happened:
| Command | Branch moved back | Staged changes | Your files | git status --short afterwards |
|---|---|---|---|---|
git reset --soft HEAD~1 | yes | kept | kept | A draft.txt; MM notes.txt |
git reset --mixed HEAD~1 (the default) | yes | unstaged | kept | M notes.txt; ?? draft.txt |
git reset --hard HEAD~1 | yes | dropped | reset to the old commit | nothing |
How to read the table
--softchanges only the branch. Nothing else moves, so everything you had stays, and the file from the commit you undid is still staged. In the status,A(added) andMM(changed in the staging area and again in the folder) tell you this.--mixedalso empties the staging area. Your edits remain in the files, but Git no longer has them staged: the status showsM(modified, not staged) and??(not tracked).--hardalso resets the files. The edit tonotes.txtis gone anddraft.txt, which was only staged, was deleted. The log shows only the older commit.
Which one to choose
- You want to commit again differently:
--soft. - You want to pick what goes into the next commit:
--mixed. - You want the work gone:
--hard, after you have checkedgit status.
The Git manual says that before reset runs, ORIG_HEAD is set to the tip of the current branch, and that --mixed is the default mode. The reflog page of this site shows how to use that to get back from a hard reset.
Does reset delete commits?
It moves the branch, so the commits are no longer reachable from it. They stay in the repository for a while and can be found with git reflog.
Is reset safe after I pushed?
Moving a shared branch back rewrites history for everyone who has it. Use git revert for shared work.
Sources
- Git documentation: git-reset (git-scm.com/docs/git-reset)
- Git documentation: gitrevisions (git-scm.com/docs/gitrevisions)
- Git documentation: git-config, settings gc.reflogExpire and gc.reflogExpireUnreachable (git-scm.com/docs/git-config)
- Git documentation: git-revert (git-scm.com/docs/git-revert)
Read on 14 November 2026.
This is an independent guide. It is not connected with the Git project, GitHub, GitLab or any company named here. Every command below was run on 14 November 2026 with the real program (git version 2.56.0.windows.4) in a new empty practice repository; the output shown is what it printed. Facts about options were read in the official Git documentation on 14 November 2026.