I have a few files I made changes to.
Then I committed it and realized I made a change to a file I didn't want to change. How can I get the file back to its original state? I am on a branch.
git checkout --file
didn't do anything at all.
git checkout filename
will work in most cases, unless you have a branch with the same name as a file. In either case,
git checkout -- filename
will be sufficient.
You need a space between --
and your filename:
git checkout -- filename
Try
git checkout HEAD~ filename
instead.
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