ShareYourGroupShareYourGroupGit Help

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:

CommandBranch moved backStaged changesYour filesgit status --short afterwards
git reset --soft HEAD~1yeskeptkeptA draft.txt; MM notes.txt
git reset --mixed HEAD~1 (the default)yesunstagedkept M notes.txt; ?? draft.txt
git reset --hard HEAD~1yesdroppedreset to the old commitnothing

How to read the table

Which one to choose

  1. You want to commit again differently: --soft.
  2. You want to pick what goes into the next commit: --mixed.
  3. You want the work gone: --hard, after you have checked git 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.