I want to revert a file to its state on its last commit.
I have modified, added and committed other files. But there is that one file that I didn't stage.
I want to revert it's state (only the state of that file) to the last commit that that file was committed.
In other words, I just want to ignore the last changes made to that file and restore it to the last point it participated in a commit.
You can use:
git checkout <file-with-path>
Or
git restore <file-with-path>
Git checkout would work if you had already committed the file. If the file was already staged you could add --staged flag to git restore to restore it as well.
https://git-scm.com/docs/git-restore
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With