avatar Deluxe Blog Tips About Projects

Git - Reset or revert a commit pushed to remote

Sometimes after you push some commits to the remote, you realize that there is a mistake. So you need to revert all of the commits that already pushed. To do so, run these commands:

git checkout master
git reset --hard e3f1e37
git push --force origin master

Where e3f1e37 is the commit you what to reset to.

Running first 2 commands will reset your code to the commit e3f1e37 in --hard mode. That means Git will remove all your local changes.

The final command runs a forced push, telling the remote to update the branch to the same as your local branch.

🔥 HOT: Interested in boosting your WordPress SEO? My Slim SEO plugin is a super lighweight and automated plugin that handles most the hard work for you: meta tags, sitemap, redirection, schema & link building.

👉 Have a look and you will love it: wpslimseo.com

Comments