You need to undo changes made in a commit
All you need to do here is to call the log, get the ObjectID of the commit you want to undo and call:
git revert ObjectID
Let's go back to the log:
Figure 12.3: Log, starting point
Now let's revert the commit that added the hello message:
git revert c507abf
Because I reverted a change in the middle of the branch, it's no surprise that I run into a merge conflict:
Figure 12.4: Merge conflict
To solve this I will call git mergetool
, invoking the tool I set up in Chapter 4, Merging, Pull Requests, and Handling Merge Conflicts. Kdiff3 is smart enough to fix all the conflicts without my help:
Figure 12.5: Kdiff3 fixes the conflicts for me
Sure enough, when we open Program.cs
the Hello World is gone:
Figure 12.6: Program.cs after revert