[2020-01-24] Revert a Single File in Git
Revert a single file to its previous status.
the file isn’t committed yet:
git checkout filename
the file is already committed:
filename is the path to the target file, hash is the hash of the commit you want to switch to.
git checkout hash filename # or git reset hash filename
If there are changes across several commits to a file we can use a branch too instead of a hash:
git checkout master -- filename