14

Is there a way that I can set Visual Studio Code as the default diff/merge tool in Sourcetree on Mac?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ozzotto
  • 1,146
  • 3
  • 13
  • 30

3 Answers3

20

You need to do below configuration in Sourcetree

  • Go to Sourcetree → PreferencesDiff
  • In the section External Diff / Merge, select Custom for the Visual Diff Tool and Merge Tool
  • Diff Arguments → --diff --wait "$LOCAL" "$REMOTE"

  • Merge Arguments → -n --wait "$MERGED"

  • After configuration is saved, then goto the Sourcetree and right click on the file with merge conflicts Resolve ConflictsLaunch External Merge Tool

Note: Diff and Merge command should point to /usr/local/bin/code and not code otherwise it will not work

Sourcetree external diff/merge tool configuration Step to resolve conflict in source tree

Swapnil
  • 1,004
  • 1
  • 13
  • 21
  • 3
    May also need to add `code` to your path https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line – g2server Nov 14 '21 at 22:45
5

According to the documentation I found, Sourcetree just uses whatever you've configured your Git repository to use.

You can configure your Git repository to use Visual Studio Code with the git config command like so:

git config --global core.editor "code --wait"

However, you must configure Visual Studio Code to launch from the terminal before this will work.

See this blog post for more information.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
JDB
  • 25,172
  • 5
  • 72
  • 123
5

I found this with instructions on how to get it to work on the Mac. I wasn't able to get it to work until I used the full path to the code executable (I also set code in my global path)

/usr/local/bin/code
bcr
  • 1,983
  • 27
  • 30