Google News
logo
Git - Interview Questions
How to revert a bad commit which is already pushed?
There can be cases where we want to revert from the pushed changes and go back to the previous version. To handle this, there are two possible approaches based on the situations :
 
Approach 1 : Fix the bad changes of the files and create a new commit and push to the remote repository. This step is the simplest and most recommended approach to fix bad changes. You can use the command: git commit -m "<message>"

Approach 2 : New commit can be created that reverts changes done in the bad commit. It can be done using git revert <name of bad commit>
Advertisement