Trying to Understand Revert And Merges in Git
Disclaimer: I'm not an expert in Git. This post is me trying to understand how it works, by trying to explain it to someone else. If I've said something wrong in this post, please don't hesitate to correct me by leaving a comment below or getting in touch with me.
So, in the past, I got confused by how a git revert
command affected the merges. Part of it is due to my TFS background. But anyway, as it turns out, it works exactly how it is supposed to work, once you have a better understanding of how Git works.
A git revert
rolls back a specific commit made in the repo. In addition to that, it adds a new commit to indicate that the previous commit was rolled back.
To better explain how this affects merges, I'll try to go over a scenario where I merge branches, then revert a commit in one branch, then try to merge the branches again. So here goes.
Imagine that I have two branches, develop
and master
. The develop
branch was created based off the master
branch, so they should have the same code in them.