I had pushed a commit onto master. It made sense at that time, but I soon realized it wasn't a wise decision.
Wanted to revert it but had to look out for a while to figure out how to.
Here's the procedure:
git reset --hard HEAD^
This would undo last commit.
Keep executing this command till you get to the desired top commit.
Then execute the following to finally commit to Github:
git push origin +master
This pushes the changes forcefully.