git reset

The command that moves the current branch to another commit, and depending on the mode also resets the staging area and working tree.

git reset --hard deletes uncommitted changes that Git has no copy of.

In more detail

--soft only moves the branch, leaving your changes staged. --mixed, the default, also makes the staging area match, leaving the changes in your files. --hard also makes your files match, discarding uncommitted edits for good. Because it moves where a branch points, it rewrites history, so use it only on commits you have not shared.

Example

git reset --soft HEAD~1

Related terms

Taught in

References