Is there a way that I can set Visual Studio Code as the default diff/merge tool in Sourcetree on Mac?
Asked
Active
Viewed 1.0k times
14

Peter Mortensen
- 30,738
- 21
- 105
- 131

ozzotto
- 1,146
- 3
- 13
- 30
-
The built-in `opendiff` tool on a Mac is very nice, btw. Just run `opendiff file1 file2` from Terminal. – Mark Setchell Oct 16 '17 at 15:59
3 Answers
20
You need to do below configuration in Sourcetree
- Go to Sourcetree → Preferences → Diff
- 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 Conflicts → Launch External Merge Tool
Note: Diff and Merge command should point to
/usr/local/bin/code
and notcode
otherwise it will not work

Swapnil
- 1,004
- 1
- 13
- 21
-
3May 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