Is there a way that I can set Visual Studio Code as the default diff/merge tool in Sourcetree on Mac?
Asked
Active
Viewed 7,919 times
13
Peter Mortensen
- 30,030
- 21
- 100
- 124
ozzotto
- 1,110
- 2
- 13
- 29
-
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
16
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/codeand notcodeotherwise it will not work
Swapnil
- 784
- 1
- 9
- 19
-
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,030
- 21
- 100
- 124
JDB
- 23,357
- 5
- 68
- 116