git restore
all
Restore working tree files. Requires Git version 2.23+. See also: `git checkout`, `git reset`.
More info →Options (4)
-s, --sourcebooleanRestore an unstaged file to the version of a specific commit
Example:
git restore {{[-s|--source]}} {{commit}} {{path/to/file}}-S, --stagedbooleanUnstage a file
Example:
git restore {{[-S|--staged]}} {{path/to/file}}-W, --worktreebooleanDiscard all changes to files, both staged and unstaged
Example:
git restore {{[-W|--worktree]}} {{[-S|--staged]}} :/-p, --patchbooleanInteractively select sections of files to restore
Example:
git restore {{[-p|--patch]}}Examples (7)
Restore an unstaged file to the staged version
git restore path/to/fileRestore an unstaged file to the version of a specific commit
git restore [-s|--source] commit path/to/fileDiscard all unstaged changes to tracked files
git restore :/Unstage a file
git restore [-S|--staged] path/to/fileUnstage all files
git restore [-S|--staged] :/Discard all changes to files, both staged and unstaged
git restore [-W|--worktree] [-S|--staged] :/Interactively select sections of files to restore
git restore [-p|--patch]made by @shridhargupta | data from tldr-pages