This page shows the source for this entry, with WebCore formatting language tags and attributes highlighted.

Title

Using Git efficiently: SmartGit + BeyondCompare

Description

I've written about using <i>SmartGit</i> (SG) before<fn><fn> and I still strongly recommend that developers who manage projects use a UI for Git. If you're just developing a single issue at a time and can branch, commit changes and make pull requests with your IDE tools, then more power to you. For this kind of limited workflow, you can get away with a limited tool-set without too big of a safety or efficiency penalty. However, if you need an overview or need to more management, then you're going to sacrifice efficiency and possibly correctness if you use only the command line or IDE tools. I tend to manage Git repositories, which means I'm in charge of pruning merged or obsolete branches and making sure that everything is merged. A well-rendered log view and overview of branches is indispensable for this kind of work. <h>SmartGit</h> I have been and continue to be a proponent of <i>SmartGit</i> for all Git-related work. It not only has a powerful and intuitive UI, it also supports pull requests, including code comments that integrate with <i>BitBucket</i>, <i>GitLab</i> and <i>GitHub</i>, among others. It has a wonderful log view that I now regularly use as my standard view. It's fast and accurate (I almost never have to refresh explicitly to see changes) and I have a quick overview of the workspace, the index and recent commits. I can search for files and easily get individual logs and blame. The file-differ has gotten a lot better and has <i>almost</i> achieved parity with my favorite diffing/merging tool <i>Beyond Compare</i>. Almost, but not quite. The difference is still significant enough to justify <i>Beyond Compare</i>'s purchase price of $60. What's better in <i>Beyond Compare</i><fn>? <h>Diffing</h> <ul> While both differs have syntax-highlighting (and the supported file-types seem to be about the same), <i>Beyond Compare</i> distinguishes between significant and insignificant (e.g. comments or whitespace) changes. It makes it much easier to see whether code or documentation has changed. The intra-line diffing in <i>Beyond Compare</i> is more fine-grained and tends to highlight changes better. <i>SmartGit</i> is catching up in this regard. You can re-align a diff manually using <key>F7</key>. This is helpful if you moved code and want to compare two chunks that the standard diff no longer sees as being comparable </ul> <h>Merging</h> I could live without the <i>Beyond Compare</i> differ, but not without the merger. <img src="{att_link}textmerge.png" align="none" caption="TextMerge in BeyondCompare Pro"> <ul> The 4-pane view shows left, base and right above as well as the target below, with the target window being editable. Each change has its own color, so you can see afterwards whether you took left, right or made manual changes. The merge view includes a line-by-line differ that shows left, base, right and target lines directly above one another, with a scrollbar for longer lines. The target view is color-coded to show the origin of each line of text: right, left, base or custom edited. <i>BeyondCompare</i> makes a smart recommendation for how to merge a given conflict that is very often exactly what you want, which means that for many conflicts, you can just confirm the recommendation. <i>SmartGit</i> has two separate windows for base vs. left/right and right/left vs. target. Long lines are really hard to decipher/merge in <i>SmartGit</i> </ul> <h>Integrate <i>Beyond Compare</i> into <i>SmartGit</i></h> To set up <i>SmartGit</i> to use <i>Beyond Compare</i> <ol> Select Tools > Diff Tools <ol> Click the "Add..." button Set File Pattern to <c>*</c> Select "External diff tool" Set the command to <c>C:\Program Files (x86)\Beyond Compare 4\BCompare.exe</c> Set the arguments to <c>"${leftFile}" "${rightFile}"</c> </ol> Select Tools > Conflict Solvers <ol> Select "External Conflict Solver" Set File Pattern to <c>*</c> Set the command to <c>C:\Program Files (x86)\Beyond Compare 4\BCompare.exe</c> Set the arguments to <c>"${leftFile}" "${rightFile}" "${baseFile}" "${mergedFile}"</c> </ol> </ol> <h>Update March 11th, 2021</h> I was testing the Git support in Visual Studio Code and ran into a somewhat surprising limitation. For those that use IDE Git integration without an external tool, this would be a pretty disappointing message. What do you do then? <img src="{att_link}vscgitcannothandletoomanychanges.png" href="{att_link}vscgitcannothandletoomanychanges.png" align="none" caption="VS Code Git overwhelmed" scale="50%"> <hr> <ft>In <a href="{app}view_article.php?id=3216" date="December 2016">Git: Managing local commits and branches</a> and <a href="{app}view_article.php?id=2780" date="February 2013">Programming in the <del>modern</del>current age</a></ft> <ft>I am in no way affiliated with <i>SmartGit</i>.</ft> <ft>I am in no way affiliated with <i>BeyondCompare</i>.</ft>