Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,811
Community Members
 
Community Events
184
Community Groups

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?

3 answers

1 accepted

0 votes
Answer accepted
Mike Corsaro
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
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
Atlassian Team members are employees working across the company in a wide variety of roles.
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.

Aha!

{
"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
Atlassian Team members are employees working across the company in a wide variety of roles.
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:

HOMEDRIVE=H:
HOMEPATH=\

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.

Like matforest likes this

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

https://danlimerick.wordpress.com/2011/07/11/git-for-windows-tip-setting-home-and-the-startup-directory/

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:

setx HOME %USERPROFILE%
Like Pawel Cioch likes this

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

Worked for me as well. Thanks!

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

In my case, I had set my user.name and user.email in the global config via Git.  However, SourceTree v3.4.6 showed the incorrect user name and email under Options | General | Default user information. 

Once I changed the Full Name and Email address in SourceTree to match that of my global config, then changes I made under Options | Diff | External Diff/Merge began to be reflected in my global config and the external diffs worked as expected in SourceTree. 

I had to do both:

setx HOME %USERPROFILE%

and 

change my name in SourceTree from James to Jim, to match my .gitconfig file. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events