Discard local changes to a file
git discard changes to file | revert file to last commit | git checkout file discard changes | git | restore | undoWarning, destructive. This command deletes, overwrites or changes data in a way that cannot easily be undone. Check every placeholder carefully and make a backup first.
git restore wp-config.phpOverwrites the file in the working directory with the version from the index or the last commit. Useful when someone experimented directly with a versioned file on a server and the clean state should be restored. With . instead of a file name, all changes in the current directory are discarded.
Note: Uncommitted changes are gone for good afterwards, and even git reflog cannot help. Check with git diff first or save them with git stash.
Also searched as
- git discard changes to file
- revert file to last commit
- git checkout file discard changes