git restore becomes easier to remember when you ask two questions: where is the content coming from, and where is it going?

1
2
3
4
5
6
7
8
# Copy the index version into the working tree.
git restore -- path/to/file

# Reset the staged version to HEAD; keep working-tree edits.
git restore --staged -- path/to/file

# Copy one file from a chosen commit into the working tree.
git restore --source=HEAD~1 -- path/to/file

The first command discards unstaged edits to that tracked file. It does not necessarily restore the last commit: its default source is the index, which may contain staged changes.

With --staged, the default source is HEAD. That makes the second command useful for unstaging without throwing away the edited file.

Before restoring working-tree content, inspect git diff -- path/to/file; inspect staged content with git diff --cached -- path/to/file. Uncommitted content overwritten by restore may not be recoverable through Git.

The -- separates options from file paths. It makes the intended target explicit and avoids ambiguity when a path resembles an option.

Reference: git-restore documentation.