git revert command
The git revert creates a brand-new commit which reverses/undoes the changes from the specified commit(s), but keep that(those) commit(s) in the branch. Because it results in a new commit, we will be prompted to enter a commit message.
Syntax git revert <commit-hash>
Note: We can use the git log command to see the commit hash.
Here, we are reverting the 656skl5 commit, we can see it creates a brand-new commit with a new hash, with reverses the changes of the specified commit.
After running the git revert command, the status is shown in the image below.
We have many options which we can use with git revert: a) -e: It is used to edit the commit message before reverting the commit. It is a default option in git revert command.
Syntax git revert -e <commit-hash>
b) --no-edit: With this option, git revert will not start the commit message editor.
Syntax git revert --no-edit <commit-hash>