Navigate to your repository that contains the commit you would like to delete.
Type the following command to perform a git reset. This will delete your commit locally.
git reset --soft HEAD~ [[Enter]]
Next, enter the following command to perform an interactive rebase. This is necessary if you wish to delete a commit that is not the most recent. Replace the number 12 with whichever number commit you are deleting.
git rebase -i HEAD~12 [[Enter]]
You will still have to push changes if you want to update any remote repositories. To do this, you must use "force push" to make everything work. Input the following command:
git push origin main --force [[Enter]]
Was this Scribe helpful? Save this document for future reference.
0 Selected
This Scribe is in tip-top shape!Leave feedback if there are any issues with this Scribe
Have something to say?Create an account to leave messages for the author to see!
Press space bar to start a drag.
When dragging you can use the arrow keys to move the item around and escape to cancel.
Some screen readers may require you to be in focus mode or to use your pass through key