The git revert command is used to ‘undo’ the changes you have made in the past. Simple. But unlike other undo commands, git revert will introduce a new commit that has the inverted changes.
For example, consider the below git history.
Assume “E” is the bad commit and you no longer need those changes. So you have decided to undo the changes that E did. You have decided to go with the git revert.git revert will always take a commit hash. So you need to pass the commit you need to revert.
And after reverting E the commit history will be changed as below.
E’ is the reverted commit. E’ will contain the reverted changes of E. But you can see that in the git history commit E is also present. And changes made by E is no longer present in the working directory.
This is one of the advantages of git revert. In this case, the git history is very clean and everyone reading the git history will understand that the particular commit has reverted for some reason.

#coding #software-engineering #software-development #programming #git

How git revert works
1.80 GEEK