It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Setup Sourcetree to use Visual Studio Code as External Diff Edited

Joe Payne Dec 08, 2017

I'm using a Macbook Pro and have installed both Visual Studio Code (with command line) and Sourcetree.  I used sourcetree to setup the external diff tool.  And can confirm git is using it by going to a directory with changes and running "git difftool".  This will launch vscode diff on the files in the directory.  But whenever I right click a changed file in Sourcetree and select External Diff nothing happens.  I verified there are no other git config files by using:

find /my/home/dir -n ".gitconfig"

 

Here is my .gitconfig

[code]
editor = code --wait
[merge]
tool = sourcetree
[diff]
tool = sourcetree
[difftool]
prompt = false
[difftool "sourcetree"]
cmd = code --wait --diff $LOCAL $REMOTE
path =
[mergetool "sourcetree"]
cmd = code --wait $MERGED
trustExitCode = true

 

Is there some step I'm missing or something I did incorrect?

Screen Shot 2017-12-08 at 12.40.03 PM.png

2 answers

2 votes
Daniel Smith I'm New Here Mar 12, 2019

I had better success. I have to set the command as follows:

 

/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron

The args were as above and work. Note the \ slashes to escape the spaces... without these it fails silently.

0 votes
Michael Minns Atlassian Team Dec 08, 2017

Hi

I think its just a case of double dashes, --wait and --diff

Joe Payne Dec 08, 2017

I noticed that after I had changed to the full name when updating the pasted config.  I had -w and -d in the file itself but I do have --wait and --diff now.  Still same result as -w and -d.

Joe Payne Dec 08, 2017 • edited

I have also tried both embedded git and installed git.

Michael Minns Atlassian Team Dec 08, 2017

Interesting it is working for me

Joe Payne Dec 08, 2017

I'll try completely removing sourcetree and reinstalling.  I already did the same for visual studio code.

Joe Payne Dec 08, 2017

Still not working after complete reinstall of sourcetree.  Followed these directions and even removed the app before starting over.

https://confluence.atlassian.com/sourcetreekb/how-to-wipe-sourcetree-preferences-412484640.html

Michael Minns Atlassian Team Dec 08, 2017

No I don't think doing that to Sourcetree will change anything.

Playing around with it I followed the settings described here to get it working from the command line, then tried transposing them into the Sourcetree settings

https://stackoverflow.com/a/36644561/1297975

Joe Payne Dec 08, 2017

What does your .gitconfig look like?  I saw that article and don't see where mine is different.

Joe Payne Dec 08, 2017

Should the diff show under Command History?  Because it doesn't.

Michael Minns Atlassian Team Dec 08, 2017

Ah, sorry my mistake I overlooked the fact you are on macOS. I'm on Windows.

I will have to try and reproduce it on there. Sorry for any confusion.

Joe Payne Dec 08, 2017

I made a simple little script to log the call and its not even logging anything.  Its as if sourcetree is not executing it at all.

 

/usr/local/bin$ cat code.sh
echo "Entered: " $@ >> /usr/local/bin/code.txt
/usr/local/bin/code "$@"
Joe Payne Dec 12, 2017

Have you been able to replicate on a Mac?

Michael Minns Atlassian Team Dec 15, 2017

Hi 

Sorry for the late reply, no I cannot get it to launch on macOS at the moment. The Sourcetree setup and the manual setup in my config look the same, but while I can launch vscode via:

git difftool

I can't get it to launch via Sourcetree. I will pass it along to my macOS colleagues.

G A Nov 01, 2018 • edited

So is there any update here or like an issue that we can track? 

 

It's still not working with VS Code 1.28.2 and Sourcetree 3.0

Zoltán Ulrich Nov 14, 2018

I had the same problem and I got it working by using the full path to the code executable, like this: /usr/local/bin/code

Screenshot 2018-11-14 at 13.44.16.png

Like # people like this

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Sourcetree

Sourcetree for Windows - CVE-2019-11582 - Remote Code Execution vulnerability

A vulnerability has been published today in regards to Sourcetree for Windows.  The goal of this article is to give you a summary of information we have gathered from Atlassian Community as a st...

465 views 0 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you