Native Merging and Conflict Resolving in GitBrowser
This week is another big week for GitBrowser. Among a whole bunch of new features (and a new platform!) discussed in this separate post, GitBrowser has gained native support for resolving merge conflicts via its own new internal three-way diffing tool and with the optional assistance of CodeBot, of course.<br>Merge Failed! 😨<br>We've all been there! You merge or pull to get some new changes, and instead of it all going smoothly to plan, Git has other ideas and shows the dreaded "there are conflicts" message. Your co-worker changed some of the same areas of code as you, and now you gotta sort out the mess!<br>As of this week, GitBrowser has not only added UI for performing merges, but it is also fully aware that they can fail and what to do if that happens. It all starts with this message:<br>I merged a branch, and now there are a total of NINE files that have conflicts and need fixing. This includes one that both my colleague and I added separately. Ouch.<br>We have options right from this sheet to try and resolve the merge (or to give up),  but first let's dismiss this sheet and see what our current state looks like:<br>We see the nine conflicting files highlighted in red, and when we look at their contents, we see those dreaded markers – the place where Git kept both versions of the conflicting code and now wants us to make heads or tails of it.<br>Luckily, GitBrowser has options. If we click the "Options " button, we get the same four choices we already saw in the sheet earlier:<br>The last two choices mean giving up. "Abort " will try to revert the Merge as if it never happened, while "Quit " will pretend all is hunky dory and there's no problem – but leave all conflicted files untouched.<br>You'd normally only use either of these options in an emergency. Abort, if you just don't want to deal with this merge now. Maybe you'll ask your co-worker to merge instead, or you just want to leave the problem for another day when you have the time. Quit is even rarer to use; use it when you just wanna deal with the whole mess manually.<br>Resolving Conflicts<br>More interesting are the two "Resolve * " options. They both show a similar UI and will give you the tools to review the conflicts, fix them, and complete the merge successfully.<br>Let's look at "Merge Manually " first.<br>It will open GitBrowser's "Resolve Merge Conflicts" sheet, which lets you inspect the conflicts for all nine files individually, review what's wrong, and manually fix them.<br>You will see your local version on the left, and the remote version on the right. Initially, you have two options for what to see in the middle pane: the current conflicted (broken) local file with both sets of changes, or the original base file with neither of them.<br>Personally, I like to start with the conflicted file, as it gives a clearer view of where the problems were.<br>No matter which option you choose, the center pane is editable, so you can go ahead and make changes there to address the conflict. You might decide to keep your version of the code, or the one from the right. More often, you will want to rewrite the conflicting code to combine the changes. As you make changes, these changes become your new local file. (The original "Base" and "Conflicted" versions remain available if you want to view them or start fresh after making a mistake.)<br>Go through each of the files and address each of the conflicts they have, until all is resolved.<br>Hint: GitBrowser will monitor for external file changes. Once you think you have fixed all conflicts, it is a good idea to keep the sheet open, switch over to your IDE of choice, and build/test the project to see if everything is good or if you missed something. You can keep making changes in your IDE or in GitBrowser until everything is good.<br>Once you're happy, click "Mark Resolved". When you close the sheet, you will see the red banner on the right turned green – you can now commit your merge as you would any other change, via the "Commit" button.<br>Resolving Conflicts with CodeBot<br>More interesting is the "Resolve w/ CodeBot " option. UI-wise, it looks and works much the same as the manual resolve – except that CodeBot does most or all of the heavy lifting for you:<br>At the very top, you see that CodeBot provides a general summary of its findings for the merge. It also tells us it found merge suggestions for eight of the files, while there's one left that it didn't know how to solve, and that we need to address manually. You can see each file in the dropdown marked with one of three status colors: green, CodeBot was able to resolve this file fully; Yellow, CodeBot solved some conflicts in the file but not all (not visible in this example), and Red, CodeBot could not fix this file at all.<br>For files that CodeBot solves (fully or partially), there are now three options available in the center pane, with Suggestion being the new one and selected by default. This version shows the suggested conflict resolution CodeBot...