Setting up LVCompare and LVMerge
EDIT: Since I originally wrote this post, I have come up with a much easier way. I am leaving this post up for historcial reasons, but do yourself a favor and just go here
There has been some discussion on LinkedIn and other places about how best to setup LVCompare and LVMerge. These tools have been around for a while, yet discussions on how to set them up and get them working still persist. If you look on the forums you can find posts from going on 10 years ago.
Part of the problem is that preferences have changed over the years as far as the Git client of choice. For a while it was TortoiseGit, then SourceTree and now it has moved onto other GUI tools such as GitKraken and Fork. Each GUI has a different interface for setting it up. Some worked with LVCompare and LVMerge out of the box and some required special wrappers. It is certainly confusing, but the information is out there. I am going to try to distill it all into one spot. I hope I am not just adding to the noise.
I’d like to share what I do that seems to work both from the CLI and from all the various GUIs. All of the GUIs (I’ve only tested Source Tree, Tortoise Git, and Git Kraken) seem to recognize an external diff/merge tool that is set in the gitconfig file right off the bat, so there should be no additional configuration needed. Simply set this up once and then it should work with the CLI and any client.
Setup Steps
- Clone this GitHub repo: https://github.com/smithed/vicompare.git (not my repo – created by Daniel Smith of NI)
- Open the LabVIEW project and build each build spec in order (there should be 4 and they are numbered)
- Run the installer you just built.
- Then run the shell commands shown below.
git config --global diff.tool LVCompare
git config --global difftool.LVCompare.cmd 'C:\\viscc\\vidiff.exe "$LOCAL" "$REMOTE" -nobdcosm -nobdpos'
git config --global merge.tool LVMerge
git config --global mergetool.LVMerge.cmd 'C:\\viscc\\vimerge.exe "$BASE" "$REMOTE" "$LOCAL" "$MERGED" -nobdcosm -nobdpos'
The Git Hub repo that you clone is used to create some wrappers that handle converting the file paths. It has something to do with relative versus absolute paths. I didn’t take the time to look into it further because it simply works. The source code is there so you can certainly satisfy your curiosity. It was written by Daniel Smith, so thank you Daniel!
Usage
As I mentioned, all the GUIs I have tried will recognize if you already have an external diff/merge tool defined in your gitconfig. You just need to figure out how to call the external tool from your GUI. Typically right-clicking on a file will give you an option to open it in an external diff tool. From the CLI, the commands you want are git difftool
and git mergetool
.