git-restore
Restore working tree files from index or commit
TLDR
Restore an unstaged file to the staged version
Restore an unstaged file to the version of a specific commit
Discard all unstaged changes to tracked files
Unstage a file
Unstage all files
Discard all changes to files, both staged and unstaged
Interactively select sections of files to restore
SYNOPSIS
git restore [options] [--] <pathspec>...
git restore --staged [options] [--] <pathspec>...
PARAMETERS
--source=<tree-ish>, -s <tree-ish>
Use specified tree-ish (commit/tag/tree) as source instead of index (default: index)
--staged
Restore index entries (unstages files to match working tree)
--worktree
Restore working tree files (default unless --staged)
--overlay
Allow restoring untracked/deleted files at paths (deprecated; implies --worktree)
--ignore-unread-directory
Ignore directories that cannot be read
-p, --patch
Interactively select and apply hunks via patch mode
-R
Recurse into submodules
--progress
Display progress meter
-q, --quiet
Suppress progress reporting
DESCRIPTION
git restore restores specified paths in the working tree from the index, or restores the index from the working tree or a tree-ish. Introduced as a modern, safer replacement for git checkout <tree-ish> -- <paths>..., it separates file restoration from branch switching (handled by git switch).
Default behavior: git restore [--] <pathspec>... discards working tree changes by restoring files from the index.
git restore --staged [--] <pathspec>... unstages files by resetting index entries to match the working tree.
--source=<tree-ish> (or -s) allows restoring from any commit, tag, or tree object, e.g., HEAD~1.
Supports interactive mode (-p or --patch) to select specific hunks, recursion into submodules (-R), progress display, and quiet operation. Use --worktree explicitly for working tree (default unless --staged). It's ideal for discarding changes, reverting mistakes, or syncing trees without risking branch confusion.
Always verify with git status first, as it overwrites uncommitted data irreversibly.
CAVEATS
Destructive: permanently overwrites uncommitted changes without backup. Cannot restore tracked deleted files (use git checkout or reset). Ignores untracked files unless --overlay. Use git status and git stash first.
EXAMPLES
Discard working tree changes: git restore file.txt
Unstage file: git restore --staged file.txt
Restore from commit: git restore -s HEAD~1 -- file.txt
Interactive: git restore -p file.txt
HISTORY
Introduced in Git 2.23.0 (5 August 2019) to refactor git checkout's file restoration, improving safety and clarity. Evolved with options like --patch in later releases; now standard for path-based restores.
SEE ALSO
git-checkout(1), git-switch(1), git-reset(1), git-stash(1)


