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

Sourcetree Won't Launch External Diff Edited

I was previously using an older version of Sourcetree, and I'd have to keep setting up the external diff tool on every restart of the program.  I found a post here that said that was a known issue, and it was fixed in the latest version.  So I updated to 3.1.3 for Windows, and while the Tools->Options->Diff menu does remember what I put in there now, it doesn't do anything anymore.

When I try to run one, the Process Log says this:

"Command": "git\r\n-c diff.mnemonicprefix=false -c core.quotepath=false difftool -y --tool=sourcetree be772c0da4337819b46177dcd6ada189b9cbb464^..be772c0da4337819b46177dcd6ada189b9cbb464 --\r\nble/Source/hal_vault.c",
"Directory": "C:\\Project\\Main",
"Status": "Finished",
"Duration": "00:00:01.0446160",
"CallerContext": "GetExternalDiffProcess",
"Output": "Unknown merge tool sourcetree\nfatal: external diff died, stopping at ble/Source/hal_vault.c\n"

I've seen this topic multiple times on here, but none of the solutions seem to be applicable to my situation.  I have "Allow Sourcetree to modify your global Git and Mercurial config files" checked.  But if I change the tool from within Sourcetree, my .gitconfig file doesn't change.  And if I run the command from the log above through the terminal, MINGW64 doesn't give me the error message.

So I don't think Sourcetree knows where my .gitconfig file is located.  I found another thread that said it first looks in the path defined by the HOME environment variable; I didn't have one, but I created it, and that still didn't help.  So how do I tell Sourcetree where my .gitconfig is, or what other issue am I missing?

2 answers

1 accepted

0 votes
Answer accepted
Mike Corsaro Atlassian Team Jul 23, 2019

Hello! There's multiple locations that your .gitconfig can be located: local, global, and system wide.


Sourcetree sets the diff config at the global level -- which should be located in "C:\Users\USERNAME\.gitconfig". We don't actually look for a file path, but instead tell git to set the config value with the --global flag set.


So for example, this is what my difftool config looks like using TortoiseMerge:

[difftool "sourcetree"]
    cmd = 'C:/Program Files/TortoiseSVN/bin/TortoiseMerge.exe' \"$LOCAL\" \"$REMOTE\"
    prompt = false
[mergetool "sourcetree"]
    cmd = 'C:/Program Files/TortoiseSVN/bin/TortoiseMerge.exe' -base:\"$BASE\" -mine:\"$LOCAL\" -theirs:\"$REMOTE\" -merged:\"$MERGED\"
    trustExitCode = true


So now I wonder why git isn't setting the file. Are you using the system-wide install of git, or the embedded install (you can check in Options > Git)?

Using System Git.  And the config file I've been checking to see if Sourcetree would change is at C:\Users\chunt\.gitconfig but it's not writing to that one.

Mike Corsaro Atlassian Team Jul 23, 2019

Could you open the process viewer (Tools > Process Viewer...), set the diff tool, then close the options window. Then look at the process log for an item that looks like this:

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks config --global difftool.sourcetree.cmd


As a work-around, you can save that process log to a file, then find item in the file that contains the command to set the diff tool and run it. I'd be interested in getting a copy of that log too if possible.


"Command": "git -c diff.mnemonicprefix=false -c core.quotepath=false config --global difftool.sourcetree.cmd \"'C:/Program Files/TortoiseHg/lib/kdiff3.exe' \\\"$LOCAL\\\" \\\"$REMOTE\\\"\"",
"Directory": "C:\\Users\\chunt\\AppData\\Local\\Temp\\",
"Status": "Finished",
"Duration": "00:00:00",
"CallerContext": "SetGlobalConfig",
"Output": "error: could not lock config file U://.gitconfig: No such file or directory\n"

Looks like it's looking for it in a nonexistent U: drive.  I mapped U: to my C:\Users\chunt folder and now Sourcetree writes to .gitconfig and launches the external diff.  Thank you!

Pretty sure the previous version I upgraded from didn't look there, and it's not getting that drive letter from any Path or environment variables.  Let's say I didn't want to have to map the drive though; is there a way to tell Sourcetree not to look in "U:\"?  Why does it look there by default?

Mike Corsaro Atlassian Team Jul 23, 2019

So it's not actually Sourcetree that's looking in "U:\", but git itself. My bet is that your "HOME" environmental variable is set to "U:\" when it should probably be set to "%USERPROFILE%"

Well, like I said before, I didn't have a "HOME" environment variable before, and the first thing I tried was to add one and set it to %USERPROFILE%, or at least the literal path.  That didn't work; it still tried to find it in "U:\" which didn't exist.

If that's a git thing, odd it doesn't do it from the command line; "git config --global --edit" finds the file in %USERPROFILE% without a "HOME" environment variable and no "U:\" drive mapped.

I'll happily map it again and leave it that way since that makes everything work.  But I still don't know where git is getting "U:\" from.

Like # people like this

I had the same problem, except git/sourcetree was trying to use H:\ as the drive.  I'm using embedded git and I didn't have a HOME environment variable.  However, it looks like my computer has the following environment variables:


I think these are set by the network administrator through Active Directory.  I don't actually have an H drive. 

I created a HOME environment variable and set it to %USERPROFILE% to fix it.  I had to restart source tree and unregister/reregister the external diff tools.  After that I'm able to use external diffs.

Setting the HOME environment variable got me up and running to! So many hours wasted on this...

Thank you!

Like Joanna Porwoł likes this

@Chris_Hunt- i am having the same issue. Lost 2 hrs to this now.

I don't have a Home environment variable.

The ProcessViewer is telling me it is looking for my global git config file on the Q Drive. I don't have a Q Drive.

When I load gitbash terminal, it is picking up all of my settings from my c drive userprofile location. Which is correct. So I am at a loss here really.

@Aaron Carlson  How did you change your HOMEDRIVE? if i create a HOMEDRIVE environment variable, its like it has no effect.  

@Mark_Menssen, I created a home environment variable, not homedrive. 


You can use the SETX command from an elevated command prompt to do this.

For example:


Oh ok, not sure why I kept thinking it was HOMEDRIVE.  Great this worked for me! Thank You!

@Adam_Hilton- is another viable answer. This is what worked for me in the end.

Suggest an answer

Log in or Sign up to answer
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...

4,917 views 0 12
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