First, find the commit and the path to the file.
Then run the following.
git checkout <commit sha> -- path/to/the/file.txt
If the file has been deleted then you'll need to look at the parent commit of the commit you want. This is done with "~1".
git checkout <commit sha>~1 -- path/to/the/file.txt
Then, commit the changes.
git commit -m "Reverting path/to/the/file.txt changes."
An alternative method is to use "git apply".
git show <commit sha> -- path/to/the/file.txt | git apply -R
You will still need to commit the changes after this patch has been applied.
Add new comment