Delete commits fully

  1. Get the logs for the last commits

git log -n 3 
# 3 means to list the latest 3 commits

2. Rebase to the previous commit that you want to commit to

git rebase -i 77d55bd72c63d43cc83f9c0fea4990c33527c2a6

3. Should enter a screen where you should pick the commit that you want

This screen works like VIM so use dd to delete all commits that you don't want.

Leave only the one you want to revert back to

3. Commit the changes

You need to use the -f flag in order to be able to do this. Otherwise it will not allow you to do that

Another option

Use the following code to reset head

Last updated