LinuxCommandLibrary

git-restore

Restore working tree files or unstage changes

TLDR

Restore working tree file

$ git restore [file]
copy
Restore from specific commit
$ git restore --source=[commit] [file]
copy
Unstage file
$ git restore --staged [file]
copy
Restore all files
$ git restore .
copy
Restore both staged and working tree
$ git restore --staged --worktree [file]
copy
Interactive restore
$ git restore -p [file]
copy

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.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community