Home » Source Code Management ( SCM ) » Git » How to delete committed message from local and remote repository in Git ?

How to delete committed message from local and remote repository in Git ?

Today I wanted to commit some message on development branch, and push it to development branch on the remote git repository, but mistakenly I did modified code on master branch, committed and also pushed it to remote master branch. But since, I didn’t wanted to touch the master branch and do all work on development branch, now I am at problem and wanted to remove all traces of changes I did to master branch. This is how, I did it.

$ cd my_source
$ git branch

This is to make sure we are on right branch.

$ git reset HEAD^ --hard

This git command will delete the last commit from the current branch.

$ git push origin --all -f

This will now force push the changes I did on local repo to the remote repository, making sure it also deletes the changes I had pushed to remote branch.


Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment