Discard uncommitted changes in one file
Build a paste-ready command, then review its compatibility and effects before running it.
Complete required fields to copy the generated command.
Destructive command. Review the target and use a preview or dry-run variant first. Safer first stepgit diff -- {{file}}Run this lower-risk preview or inspection variant before the state-changing command. Compatibility
Linux + macOS + WindowsVerified for Linux, macOS, Windows using bash, zsh, powershell syntax.
Operational knowledgereview due 2027-01-19
Requirementsgitgit must be installed and available on PATH.
Version supportgit Current supported releasesVerified for linux, macos, windows using bash, zsh, powershell syntax; consult compatibility notes for platform-specific differences.
Expected signals(no terminal output on success)Representative successful output; values vary with the selected target and system state.
Known errorsgit: command not foundgit is missing or is not available on PATH.
Verifygit diff -- {{file}}The preview shows only the intended targets before applying the change.Rollback noteNo universal automatic rollback is available. Capture the current state and use the tool-specific recovery procedure before applying changes.
Command breakdown
01gitCommandRuns the git stage of this one-liner.
02restoreArgumentPasses restore to git.
03<file>ParameterA value supplied in the Fill parameters section.
Example input
git restore app/page.tsx
Example output
(no terminal output on success)
app/page.tsx is restored from the index or HEAD.
Illustrative output — exact values vary by system and data.
Runbooks
Official sources