I have mistakenly edited my local html file. I had committed the changes before the current edits. How can I get the previous content of my html file on GitHub after editing the local file.
Asked
Active
Viewed 49 times
0
-
2Does this answer your question? [Hard reset of a single file](https://stackoverflow.com/questions/7147270/hard-reset-of-a-single-file) – Daniel Mar 16 '22 at 10:19
-
Why involve Github? Just discard your local changes and recover the previous version from your already-checked-out code – Quentin Mar 16 '22 at 10:20
1 Answers
0
If you've not committed the erroneous changes locally use:
git restore <file name>
This will erase your changes and restore the file to its state as per the last commit.
If you have committed, use:
git checkout HEAD~1 <file name>
This will checkout the file as it was one commit back, i.e. the one before your erroneous one. If you then decide you want to keep your changes you can do git checkout HEAD <file name>
to get back to the most recent commit version.

askman
- 447
- 4
- 14