One or more commits can be reverted through the use of git revert. This command, in a true sense, creates a new commit with patches that cancel out the changes introduced in specific commits. If in case the commit that needs to be reverted has already been published or changing the repository history is not an option then in such cases, git revert can be used to revert commits. If you run the following command then it will revert the last two commits:
git revert HEAD~2..HEAD
DevOps Training
Alternatively, there is always an option to check out the state of a particular commit from the past and commit it anew.