Restore-File Restore a single file to its last saved state without touching anything else.
Description
Restore-File is the targeted GitEasy restore. It resets one file to its last saved version while leaving every other change in the active working area alone.
Use it when you want a precise rollback of one file - for example, a generated file you accidentally edited, or a configuration file you want to revert without abandoning the rest of your work.
Each invocation writes a self-contained diagnostic log file. Successful runs log silently; failures throw a plain-English message and point at the log file with the technical detail.
Recipes
Recipe 1
EXAMPLE 1
Restore-File -Path README.md
Recipe 2
EXAMPLE 2
Find-CodeChange; Restore-File -Path Public\Save-Work.ps1; Find-CodeChange
Notes
Safety:
- Refuses to run during an unfinished merge, rebase, cherry-pick, revert, or bisect.
- Refuses to run while there are unfinished conflicts.
- Refuses to operate on a file that does not exist or is not tracked.
- Run Save-Work -NoPush first if you might want the discarded edits later.
Parameters
-Path required String
Path to the file to restore. Can be relative to the current location or absolute. Must be a tracked file in the active project.
-LogPath optional String
Override the directory where the diagnostic log for this run is written.
-WhatIf optional SwitchParameter
-Confirm optional SwitchParameter
Was this page helpful? Report an issue or suggest an improvement →