# Git Reset

> Moving a branch back to an earlier commit. Later commits drop out of it.

**Field:** Software Development  
**Category:** Version Control  
**Also known as:** git reset, git reset --hard, Reset a Branch

## Think of it like

Think of it like moving a bookmark back a few pages. The pages after it no longer count.

## Definition

Git reset moves your branch back to an earlier commit. The commits after it drop out of the branch. The soft mode keeps their changes staged. The default, mixed mode keeps the changes in your files but unstaged. The hard mode throws the changes away, and that cannot be undone easily.

## Example

Emma made two messy commits she has not pushed. She runs git reset --soft HEAD~2 and commits again as one.

## Example code

```console
$ git reset --soft HEAD~1
$ git status --short
M  index.html
```

The last commit is gone, but its change is still staged.

## Why it matters

It cleans up local work before you share it.

## Common mistake

Running git reset --hard without thinking. Changes you never committed are lost for good.

## Three principles

- **Moves the branch.** Back to the commit you name.
- **Three modes.** Soft, mixed or hard.
- **Local work only.** Never reset what others pulled.

## Related terms

- [Git Revert](https://learn.benibix.com/term/development/git-revert)
- [Git HEAD](https://learn.benibix.com/term/development/head)
- [Staging Area](https://learn.benibix.com/term/development/staging-area)
- [Git Commit Amend](https://learn.benibix.com/term/development/git-commit-amend)
- [Git Stash](https://learn.benibix.com/term/development/git-stash)

## Told apart from

- [Git Revert vs Git Reset](https://learn.benibix.com/compare/git-revert-vs-git-reset): Git revert adds a new commit that undoes an old one, so the history stays. Git reset moves the branch back, so later commits drop off it. Use revert on shared branches, and reset only on your own work.

## Taught in

- [Undo a Git Commit](https://learn.benibix.com/learn/development-version-control/undo-a-git-commit): Git and GitHub, 7/13

![Three rows, each starting from commits A, B and C in a line. Revert, lit up, adds a new commit D that undoes C, so history only grows and is safe to share. Reset moves the branch label back from C to B, so C drops out of the branch. Amend swaps C for a new C with a fixed message or file. A note says reset and amend rewrite history, so use them only on commits you have not pushed.](https://learn.benibix.com/diagrams/dev3-undo-changes.svg)

---

Source: https://learn.benibix.com/term/development/git-reset
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
