When you want to rollback a commit.
For github, go to the github commit page, and append .patch
to the url, then you will get the patch of this commit. Save the content to a file like file.patch
.
Use this command to rollback this commit:
git apply -R file.patch
Then this commit will be rollbacked.
References:
Reversing patches