Sometimes, you commit and merge the code that breaks something or any other reasons on the application.To resolve this problem, this Git feature help you to rollback the broken code from the main branch.
Let’s say you have accidentally merged the code that you are not ready to. And you want to go back to the previous stage.
Step 1.Get Last Log Details
There is a particular COMMIT_ID that defines the commit that we had done earlier.For ex.
Step 2.Get the last Commit ID
The git revert command is used for undoing changes to a repository’s commit history.
Step 3.Revert Commit
git revert COMMIT_ID
Previous command will revert the last commit from the local repository.You need to run push to change the same thing on the remote repository as well.
Step 4.Push the Commit
Finally🙌, you have safely reverted or undo the last commit from the main branch.in this way you can roll back a mistaken or unwanted merge and work more efficiently with Git.