How to Discard Last Commit in Git after Push

Hello devs,

In this example, I will show you how to revert last commit in git after push. Sometimes we need to discard last commit in git and if you don't know how to do it then this example is for you.

From this example, you will learn how to discard last commit in git. To get git revert last push, just run those below commands:

// Go to previous commit
git reset --hard HEAD~1 

//or run
git reset --hard HEAD^

// Force push
git push -f 

 

Hope it can help you.

 

Facebook Github
A web enthusiastic, a self-motivated full-stack software engineer from Dhaka, Bangladesh with experience in developing applications using Laravel , React and Vue js