Revert and forget - Anjum219/Git-basics GitHub Wiki

To revert commits that we don't wanna keep anymore, fetch the commits' hash by

git log --oneline

The hexadecimal number before a commit's name is the respective commit's hash.

Now if the commit history looks like this A <-- B <-- C <-- D <-- ... where A is the latest commit and you want to revert B, C, do the following-

git revert --no-commit <commit_hash_of_C>
git revert --no-commit <commit_hash_of_B>

The --no-commit prevents git from writing an auto commit message for the reverting. So, if you use --no-commit, don't forget to make a commit message afterwards-

git commit -m 'revert . . .'