In this article, We will explain how you can reset, revert your master branch changes to the previous state.
Example Revert From Master
For example, your master branch is pointing to feature 1.2 (commit af2w4)
and you want to revert back your changes to feature 1.1 (commit wd2e4)
Delete the last commit
Deleting the last commit is a simple case. Let’s say we have a remote origin with a branch master that currently points to commit af2w4 and want to make the parent commit wd2e4
git push origin +wd2e4^:master
Where git interprets
x^ as the parent of
+ as a forced non-fast-forward push. If you have the master branch checked out locally, you can also do it in two simpler steps: First reset the branch to the parent of the current commit, then force-push it to the remote.
git reset HEAD^ --hard
git push origin -f
Now your master branch is pointing to feature 1.1 (commit wd2e4)