How Do I Use Beyond Compare: Introduction to Beyon
  • Forty things about Beyond Compare
  • Acknowledgements
  • Learn Beyond Compare in 5 Minutes
    • Quickstart: open two directories
    • Quickstart: open two files
    • Quickstart: move a file
    • Text Compare: understand the display
    • Downloads
  • Text Compare
    • How to use Beyond Compare for Text Compare
    • In Beyond Compare, what are unimportant differences?
    • Why no word-wrap ??
    • How to use Beyond Compare to confirm 100% replacement
    • Ignore Trivial Differences, Like Timestamps
  • Git
    • How to use Beyond Compare with Git
    • Do a roll-back to peek at your old code
    • Quickstart: Folder Merge
    • Why merge three folders?
    • Beyond Compare Three-Way Folder Merge Symbols Explained
    • How to compare two commits, both old, in Git
    • Git mergetool: merging three files.
    • How to recover an older version of your code with Git and Beyond Compare
    • Peeking under the hood at how Git does its thing
    • Getting better at Git
    • Find changes since last commit
    • Patches
    • How to configure Visual Studio to use Beyond Compare for Version Control
  • Scripts and the Command Line
    • How to use Beyond Compare in the Terminal
    • How to do an automatic backup every day
    • Write a Batch File That Will Start Several Syncs Simultaneously
    • Write a batch file that will start several text compares automatically
    • TL; DR
  • Table Compare
    • Quickstart: open a couple of Excel spreadsheets
    • Example: finding missing items in a pair of spreadsheets
    • Keys
    • Mismatched Columns
    • Longer example, opening .csv files
    • How to remove columns from a spreadsheet
    • Aligned vs Unaligned
    • Example: List of City Trees
  • Sync / Folders
    • Backup your entire computer (Part One)
    • Backup your entire computer (Part Two)
    • Backup, advanced
    • RegEx Examples: Filename Alignment Overide
    • Scan a lot or a little
  • Other
    • Peek
    • Binary
    • Undo
    • Colors
    • How to compare images
    • Report: Text Compare
    • Report: Table Compare
    • Looooonnnnngggg lines...
    • Binary: How to see the 1's and 0's
    • How to write your first script
    • How to find redundant or duplicate files
    • Minor Edge Cases
    • Shortcut Key
    • How to ignore parts of your file
    • Folder System Context Menus
    • About Evan Genest
Powered by GitBook
On this page
  • Why merge with a GUI mergetool?
  • Step by step: how to fix a merge conflict with a Git mergetool
  • Review
  • More help

Was this helpful?

  1. Git

Git mergetool: merging three files.

Sometimes you don't wand to merge folders, you just want to merge files. In fact, handling a Git merge is the main thing you would use BC for in Git.

PreviousHow to compare two commits, both old, in GitNextHow to recover an older version of your code with Git and Beyond Compare

Last updated 6 years ago

Was this helpful?

Why merge with a GUI mergetool?

In Git, if you edit, and commit a file from your laptop, but also edit and commit the same file in your remote repository (e.g. Gitlab), you might not be allowed to push or pull. Git may warn you that you have committed twice, and that the code is different in the two commits.

Before trying the following example, make sure your Git knows you have installed other software to help it: installation .

Step by step: how to fix a merge conflict with a Git mergetool

  • In a browser like Firefox or Brave, log into your remote repository on Github or similar. GitHub allows you to directly edit files in the browser; change some lines in your ReadMe.md. Save & Commit. Switch to your local version of that same repository and, change some different lines of ReadMe.md. Save & commit.

  • Do a git pull myRepo master . Git will complain.

  • Type git mergetool -- myFileName (assuming you already set up BC, per the link above)

  • You will see Beyond Compare open up, with not two but three versions of your conflicted file. The middle is the oldest-version, called base. This is the commit that Git has determined is the old common ancestor of your two conflicted files. It is a reference useful to both you and recently to Git's failed attempt (see screenshot above) to do an automatic merge.

  • In the BC pulldown menus: turn on View->LineNumbers to make things clearer.

  • Choose your lines by mouse clicking the blocky arrows of the versions you want. BC will suggest which version it likes by giving a different colored arrow but you are the boss, so click anything you want

  • The merge interface can get pretty crowded: to see detail, in context, make good use of the stacked racetrack in the middle.

  • Close Beyond Compare.

  • You should now be back in the terminal. At the command line check to see if everything is okay

  • Don't forget to commit your change. Best practice says to use the imperative tense, not past tense in your commit message.

Review

Merge is neccessary when your remote repo gets ahead of your local repo, sowing seeds of confusion for you as well as for Git. For trivial conflicts, Git will kindly automerge them when you type git pull thatRepo master. If the changes are more significant, however, you will need to tell Git, line-by-line which code you want to keep. Here is the sequence of steps.

  1. Git sends you a message: "CONFLICT (content): Merge conflict in yourfile.py"

  2. git mergetool -- yourfile.py

  3. when Beyond Compare opens up, press blocky arrows to choose lines

  4. hit the save button in Beyond Compare

  5. close BC

  6. important: git commit -m "Fix merge conflict."

More help

NOTE: The $30 version of BC does not have this feature, it is only in the $60 version. If you are cheap, like me, just realize that this license is a lifetime license and the program is similar to having MS Word: you almost can't live without it once you learn it. Git merges are only about 10% of what I use BC for.

Once you are happy with how the bottom pane looks hit the save key.

have a quick tutorial invoking git mergetool using the old, free tools Kdiff3 and Meld.

GitGuys
instructions link