How to Delete a Commit in GitHub | Scribe

    How to Delete a Commit in GitHub

      1
      Open your Terminal or Shell to get started.
      2
      Navigate to your repository that contains the commit you would like to delete.
      3
      Type the following command to perform a git reset. This will delete your commit locally. git reset --soft HEAD~ [[Enter]]
      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]]
      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]]