Things I Learned #13: VS Code and merging

1 minute read til learning   git   vscode Comments

Today was the day I finally got tired of dealing with using Vim as my git mergetool. I don't deal with merge conflicts enough to have built up muscle memory, but today was one of the days I needed it.

git mergetool
There I was, once again staring at vim's 3-day merge with this page open and not wanting to deal with it. Something snapped and I told myself that today was the day I would finally figure out how to use VS Code as my git mergetool. Don't get me wrong though - I love Vim and use it daily, but I knew for this one situation, something else would be work better for me.


I learned how easy it is to change git to use Visual Studio Code as my mergetool. How easy?

Here's the relevant sections from my .gitconfig, and as you can see, I also have VS Code set up as my diff tool. By the way, I talked about using VS Code as a general diff tool back in this post.

    editor = code --wait
    tool = vscode
  [mergetool "vscode"]
    cmd = code --wait --merge $REMOTE $LOCAL $BASE $MERGED
    tool = vscode
  [difftool "vscode"]
    cmd = code --wait --diff $LOCAL $REMOTE

Now, instead of this Merging with vimdiff. the merge can be done in Visual Studio Code Merging with Visual Studio Code.

While your mileage may (and probably will) vary, I prefer the more graphical natural of Visual Studio Code to manage merge conflicts. It's easy to toggle a section on and off to see what the resulting merge will look like, and it's also easier to navigate.

I know there are other tools out there (P4Merge, BeyondCompare come to mind), and I may eventually swap VS Code for one of those, but right now, I'm just happy to have something a little easier to use.