LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-reset

Reset current HEAD to a specified state

TLDR

Unstage files
$ git reset [file]
copy
Soft reset (keep changes staged)
$ git reset --soft [commit]
copy
Mixed reset (unstage changes)
$ git reset [commit]
copy
Hard reset (discard changes)
$ git reset --hard [commit]
copy
Reset to upstream
$ git reset --hard @{u}
copy
Unstage all files
$ git reset HEAD
copy
Reset single file to commit
$ git reset [commit] -- [file]
copy

SYNOPSIS

git reset [options] [commit] [--] [files...]

DESCRIPTION

git reset moves the current HEAD to a specified state. It can unstage files, undo commits, or completely discard changes depending on the mode used.The three main modes are `--soft` (keeps changes staged), `--mixed` (unstages changes, the default), and `--hard` (discards all changes). When given file paths, it unstages those files without moving HEAD.

PARAMETERS

--soft

Keep changes staged.
--mixed
Unstage changes (default).
--hard
Discard all changes.
--keep
Reset but keep local changes.
--merge
Reset to merge state.
-p, --patch
Interactive reset.
--recurse-submodules
Update submodule working trees to match the superproject.

INSTALL

sudo apt install git
copy
sudo dnf install git
copy
sudo pacman -S git
copy
sudo apk add git
copy
sudo zypper install git
copy
brew install git
copy
nix profile install nixpkgs#git
copy

CAVEATS

Hard reset discards changes permanently. Be careful with --hard on uncommitted work.

SEE ALSO

RESOURCES

Copied to clipboard
Kai