- Published on
Reverting a Single File with the Git Cli
- Authors
- Name
- Yair Mark
- @yairmark
When using an IDE like IntelliJ reverting a single file or even a single line of a file is easy using the IDE. But if you wanted to do this outside of an IDE how would you do that?
I have not worked out how to do this for a single line. But for a single file it is quite easy:
- Get the last commit hash of a file:
git log path/to/file
- Checkout that commit to rever the file:
git checkout <lastCommitHash> path/to/file
And that is it :)