No announcement yet.

Comparing a branched file - what's the next step?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Comparing a branched file - what's the next step?

    Novice question,

    I configured bc4 on Windows (as described
    But I haven't found documentation/tutorials on the next step (i.e. actually using bc to compare and resolve conflicts).

    For example, let's say I have have two branches with one file conflict.
    • Compare the branches: git difftool develop feat_myFeatureBranch
    • The command opens bc4 and loads the conflicting versions.
    • But the filepaths are in a temp directory with temp names. e.g. C:\Users\myName\AppData\Local\Temp\N8zu95_myFile.t xt
    Have I already gone wrong... or what do I do next?

  • #2
    Another way to ask my question: I know how to configure BC with Git, and I know how to use BC. What's missing is the inbetween piece: how do I load file conflicts from Git into BC?


    • #3
      Configure BC as the git mergetool, then use "git mergetool" to merge the files and resolve any conflicts


      • #4
        Thanks for this. For certain what would help is a list of common git command that load files for comparison or merge.
        But here's the thing, when I do a command like git difftool develop feat_myFeatureBranch the files loaded have temporary filepaths and filenames... they are not the filepaths of my gitlab files.


        • #5

          If you are passing branches, Git commonly generates temp locations to form those branches. For example, I'd expect at least one to always be temporary since the local folder could only be on one 'state' at that moment. Git chooses what to pass, and BC4 is only involved after the Git command line has generated the temp locations and then passed them on to BC4, so I suspect it needs to generate both if that's what it is choosing to do.

          If you pass in only a single branch name, does this then diff that branch to the local version?
          Aaron P Scooter Software


          • #6
            I've also recently started using Git (was previously using Code Co-op) and wanted to continue using Beyond Compare as my diff and merge tool. It is not a particularly satisfying experience, but the limitations are due to Git, not Beyond Compare: Git has no way to provide provide reasonable descriptions of revisions to external diff and merge tools, so temporary pathnames and filenames are exposed in the Beyond Compare window title and panel headings.

            Here are some examples for difftool.

            git difftool revision filename

            (This is the typical case for Aaron's last question.)

            Git compares a historic revision with the current working tree copy of the specified file (revision may specify a commit, branch name, tag name, or more complex forms). Beyond Compare shows a temporary file created by Git on the left side, and the actual working tree file on the right side. The temporary file has a randomly generated prefix on the base filename, which doesn't help to identify where it came from, but you should know where it came from because you specified the revision. You can edit both sides, but editing the left side doesn't achieve anything because Git ignores changes to the temporary file.

            git difftool filename

            Git compares the staged/cached state of the file (as of the last "git add" command) with the current state of the working tree. Similar pattern to above.

            git difftool revision

            This compares all changes between revision and the current state of the working tree, one file at a time. After you close the BC window for one file, Git will open BC again for the next file comparison.

            git difftool -d revision

            Directory compare revision to the current working tree. This opens a BC folder comparison between revision (left) and the working tree (right) but it uses temporary copies of files on both sides (you can't usefully copy or edit anything), and only has files which changed, were added or deleted.

            If you want to do a full comparison between branches with the ability to edit/copy, then a better method is to have both branches set up as separate git worktrees and do BC folder compare between them (you'll probably need to ignore timestamps or do a rules-based comparison).

            git difftool revision-1 revision-2 filename

            This compares a file between two historic revisions. Git creates temporary files for both revision-1 and revision-2 and sends them to Beyond Compare. Both have random prefixes on the filenames, but the order is predictable: the one on the left is revision-1 and the one on the right is revision-2. If you are doing some kind of before and after comparison between revisions then specify the "before" revision first, and it will be on the left in Beyond Compare. You can edit both sides but that won't achieve anything because Git ignores changes in both temporary files.

            I don't have anything in the right state at present to refresh my memory on how git mergetool behaves, but can report back on that later.

            I'm also exploring GUI front ends for Git, and I've found that TortoiseGit with Beyond Compare integration does a better job: it provides titles which are based on the Git SHA-1 commit ID for historic revisions (which are better than Git's random prefixes). Setting up TortoiseGit to use BC is documented here:
            Last edited by dempson; 14-Jul-2020, 10:29 PM. Reason: Added gifftool -d


            • #7
              If you don't mind, dempson, I'm going to re-word/edit this into an excellent template email we can use as a reference when people ask about Git.
              Aaron P Scooter Software


              • #8
                Hi Aaron. Fine with me (if you want my full name for reference, it is David Empson).

                It might be worth mentioning git's built-in documentation for further details on the parameters, particularly these ones:

                git help difftool
                git help diff
                git help gitrevisions

                I haven't needed to do a merge since my previous post, so can't expand on git mergetool yet.

                I was looking further into the question of "Can I do a directory compare of a historic revision with the working tree, with the ability to modify the working tree in Beyond Compare" (i.e. a more flexible variant of git difftool -d). The answer appears to "yes, but not with a simple command". The best solution I've found so far is using git archive to create a tar, piped to tar -x and tell it to output to a temp directory, then use Beyond Compare directly to do the comparison. Timestamps are best ignored, but are slightly better if you reference a tag rather than a commit (you can temporarily create a tag and delete it afterwards). The sequence goes something like this (with variations depending on which untar tool you are using; deleting the temp dir left as an exercise for the reader):

                mkdir mytempdir
                git tag tagname revision
                git archive tagname | tar -x -C mytempdir
                git tag -d tagname
                bcompare mytempdir .


                • #9
                  Thanks. If you want to keep your name here or edit it out, just let us know if you need help. I wasn't including it in any emails, as I wouldn't want anyone to try and track you down for support, but if you'd want me to, I could add it in. I just appreciate your quick summaries of frequent Git commands and think they'll be useful for some of the first time Git users that occasionally write in.
                  Aaron P Scooter Software