Sunday, August 7, 2016

Git: How to delete the last commit on remote

Let's say you accidentally commited a wrong commit to a branch or a commit to the wrong branch. What do you do?
Thankfully, Git allows you to delete the commit on remote.
Here is how.
 git pull origin mybranch  
 git reset HEAD^ --hard  
 git push origin-f mybranch  
More detailed info can be found here.