top of page
INTERMEDIATE LEVEL
Q16: How do you revert a file to a previous commit in Git?
To revert a file to a previous commit in Git, you can use the command
`git checkout <commit-hash> -- <file>`.
This command replaces the content of the specified file with the version from the given commit. It effectively discards the changes made to the file since that commit.
bottom of page