Remove commit from remote

Table of contents
  • How do I revert a previous commit?
  • Revert while keeping changes.

How do I revert a previous commit?

We can revert (means delete the bad commits) to the previous working commit. You can do this by the following two commands:

git reset --hard [previous working Commit SHA id here]
git push origin [branch Name] -f

It will remove your previous Git commits.

Revert while keeping changes.

If you want to keep your changes, you can also use:

git reset --soft [previous Commit SHA id here]

Then it will save your changes.

Imran Pollob