git-restore - Restore working tree files

Restore specified paths in the working tree with
some contents from a restore source. If a path is
tracked but does not exist in the restore source,
it will be removed to match the source.

The command can also be used to restore the
content in the index with —staged, or restore
both the working tree and the index with —staged
—worktree.

If you want to restore all C source files

$ git restore '*.c'

To restore all files in the current directory

$ git restore .

or to restore all working tree files with top
pathspec magic

$ git restore :/

Examples

# Unstage changes made to a file, same as "git reset some-file.py"
git restore --staged some-file.py

# Unstage and discard changes made to a file, same as "git checkout some-file.py"
git restore --staged --worktree some-file.py

# Revert a file to some previous commit, same as "git reset commit -- some-file.py"
git restore --source HEAD~2 some-file.py