Delete commits from a branch in Git

If you want to Delete commits from a branch in Git, Using this method, you can delete the last commit. you can see your last commit using,

git log

Then you need to reset your commit. It means reset the commit you want to delete.

git reset –hard HEAD~1

After that you have to do a force push.

git push origin HEAD –force

you can see the last commit is deleted.


Related Git commands and Tutorials.

Thank you for reading. If you are interesting on my article, make sure to follow my other articles as well. Make sure to leave a comment.

guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x