commands.sh

git restore

all

Restore working tree files. Requires Git version 2.23+. See also: `git checkout`, `git reset`.

More info →

Options (4)

-s, --sourceboolean

Restore an unstaged file to the version of a specific commit

Example: git restore {{[-s|--source]}} {{commit}} {{path/to/file}}
-S, --stagedboolean

Unstage a file

Example: git restore {{[-S|--staged]}} {{path/to/file}}
-W, --worktreeboolean

Discard all changes to files, both staged and unstaged

Example: git restore {{[-W|--worktree]}} {{[-S|--staged]}} :/
-p, --patchboolean

Interactively 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/file

Restore an unstaged file to the version of a specific commit

git restore [-s|--source] commit path/to/file

Discard all unstaged changes to tracked files

Unstage a file

git restore [-S|--staged] path/to/file

Unstage 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