GitCheatSheet.org logo
Home / How To

Revert a file using "git restore"

git restore fileToRevert.txt

Replaces the file in the working directory by the latest staged or commited file. WARNING: any local changes made to the file are lost. Git replaces the file with the last staged or committed version. Note: the "restore" command was introduced in Git version 2.23.0.