Sets the current Git repo head to a specified commit and optionally resets the index and working tree to match.
If you've made a mistake in the current working tree, and haven't committed, you can revert the entire working tree to the last commit state with the following:
$ git reset --hard HEAD
Synopsis
git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]
git reset [-q] [<commit>] [--] <paths>...
git reset --patch [<commit>] [--] [<paths>...]
Options
--mixed
Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.
--soft
Does not touch the index file nor the working tree at all, but requires them to be in a good order. This leaves all your changed files "Changes to be committed", as git status would put it.
--hard
Matches the working tree and index to that of the tree being switched to. Any changes to tracked files in the working tree since <commit>
are lost.
--merge
Resets the index to match the tree recorded by the named commit, and updates the files that are different between the named commit and the current commit in the working tree.
--keep
Reset the index to the given commit, keeping local changes in the working tree since the current commit, while updating working tree files without local changes to what appears in the given commit. If a file that is different between the current commit and the given commit has local changes, reset is aborted.
-p
, --patch
Interactively select hunks in the difference between the index and <commit>
(defaults to HEAD). The chosen hunks are applied in reverse to the index. This means that git reset -p is the opposite of git add -p (see git-add).
-q
, --quiet
Be quiet, only report errors.
<commit>
Commit to make the current HEAD. If not given defaults to HEAD.
See also
Reference
$ git reset --help