To delete unpushed git commits, you can use the git reset
command. Here’s an example of how to use git reset
to delete the last unpushed commit:
- First, use
git log
to view the list of commits in your repository.
$ git log
- Then, use the
git reset
command with the--hard
option to delete the last unpushed commit.
$ git reset --hard HEAD~1
- Finally, push the changes to your remote repository using the
git push
command.
$ git push -f
Note: The -f
option is used to force the push, which is necessary when you are deleting commits that have already been pushed to the remote repository.