git-restore

Restore working tree files or unstage changes

TLDR

Restore working tree file
$ git restore [file]
Restore from specific commit
$ git restore --source=[commit] [file]
Unstage file
$ git restore --staged [file]
Restore all files
$ git restore .
Restore both staged and working tree
$ git restore --staged --worktree [file]
Interactive restore
$ git restore -p [file]
Restore your side of a conflicted merge
$ git restore --ours [file]
Restore the incoming side of a conflicted merge
$ git restore --theirs [file]

SYNOPSIS

git restore [options] [files...]

DESCRIPTION

git restore restores working tree files or unstages changes from the index. Introduced in Git 2.23 to provide a clearer alternative to the file-restoration aspects of `git checkout`.Use `--staged` to unstage files, `--worktree` (the default) to discard working tree changes, or both together to restore a file completely to a previous state.

PARAMETERS

--source tree

Restore from tree.
-s tree
Short for --source.
--staged
Restore index (unstage).
--worktree
Restore working tree.
-S
Short for --staged.
-W
Short for --worktree.
-p, --patch
Interactive mode.
--ours / --theirs
During a conflicted merge, restore the current branch's or the merged-in branch's version.
-m, --merge
Recreate the conflicted merge state in the file.

INSTALL

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

SEE ALSO

git-checkout(1), git-reset(1)

RESOURCES

Source code · Homepage · Documentation