How to Delete a Commit in GitHub | Scribe

    How to Delete a Commit in GitHub

    • |
    • 0 step |
    • 59 seconds
      Open your Terminal or Shell to get started.
      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.
      This Scribe is in tip-top shape!Leave feedback if there are any issues with this Scribe