You can do an interactive rebase .
Assuming your head is in ab1c41c from your example, call rebase as follows
git rebase -i HEAD~7
This tells git that you want to manipulate the last 8 or so. You will be taken to your editor with a list of commits and some instructions.
Delete lines containing commits to delete, save, and exit. git will transform rebase and what it is.
Keep in mind that due to redirection, if you want to click on one branch, you need to pass the --force option.
Disclaimer Restoring and forcibly pressing can result in job loss or people being kicked out, so just make sure you understand what you are doing. :)
Blake taylor
source share