This guide was created with Scribe in 59 seconds. Sign in and create your own!
How to Delete a Commit in GitHub
|
0 step |
59 seconds
Open your Terminal or Shell to get started.
Zoom Saved
2
Navigate to your repository that contains the commit you would like to delete.
Zoom Saved
3
Type the following command to perform a git reset. This will delete your commit locally.
git reset --soft HEAD~ [[Enter]]
Zoom Saved
4
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]]
Zoom Saved
5
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.
Save for Later
Have something to say?Create an account to leave messages for the author to see!Create an account
Feedback
This Scribe is in tip-top shape!Leave feedback if there are any issues with this Scribe