

So, theirs refers to the feature branch but not master and ours will be the master branch as internally we’re on this master branch already. The key point to remember is that the feature branch was reset to the current master, and changes were applied from there onwards. The final new history looks like this: E-F-G feature The intermediate history looks like this now: E-F-G (saved in a temporary area)Īfter the reset, all the changes in the temporarily saved area (i.e “E”, “F”, & “G”), are applied in turn onto the master branch.

It’s time to merge your branch to master. feature), the master (pointer) can move forward - your colleague’s branch (testing) has been merged into the master already. While you are happily working on your branch (e.g. You can read more about this concept in official git docs and an article written by yours truly.

This is how Git knows which branch you are on. When you create a new branch off from master with git branch feature, a new pointer is created as shown in the figure below: featureĪnd when you switch branch with git checkout feature, Git moves the HEAD pointer, which was initially pointing to master, to your branch. Why do merge conflicts occur?Ī branch is just a lightweight, movable pointer to one of the commits you are on. If you already know git internals, you can skip straight to the command. In this article, I’ll first explain the reasoning behind the conflicts, and then I’ll show you a command which allows you to do the same in a few keystrokes. What if you just want to override your changes in master with another branch, or vice-versa? You can resolve all the conflicts manually by navigating to each file, and accepting all incoming changes to the master. In a few cases, it could cause merge conflicts where Git doesn’t know what to do and hands control back to you. Once your work is completed, you can merge your branch back into the master. Git branching allows developers to work in isolation. Settings Light theme Dark theme Strategies to resolve git conflicts using "theirs" and "ours"
