Cannot set system Git

I have SourceTree 1.5.2.0 installed on my Windows 7 system.  My git version is 1.9.4.msysgit.0.

I also have cygwin installed on my system and it has a git.exe of its own, but both my Windows path and my cygwin path (as set up with .bashrc) find the msysgit version first.  It is located in C:\Git\cmd\git.exe.

If I attempt to clone a valid repository, I get an error: This is not a valid source path / URL

The Details... button shows: Unknown option: -c   usage: git  <more>

-c is a valid option on the msysgit version but not on the cygwin version.

If I bring up the terminal from SourceTree then git --version produces:  git version 1.5.6.4.  This is the version of the cygwin version, not the msysgit version which is what I want.

If in SourceTree I go to Tools -> Options and then click on the Git tab, the System Git Version is reported as 1.5.6.4 (consistent at least, but still not what I want).  The Use System Git button, which presumably would let me set the version, is grayed out, so I cannot click on it.

In C:\Program Files (x86)\Atlassian\SourceTree\SourceTree.exe.config (which looks like an xml file but does not have an .xml extension)  I find the following entries, among many others:

<setting name="GitSystemPath" serializeAs="String">
<value />
</setting>

<setting name="GitWhichOne" serializeAs="String">
<value>-1</value>
</setting>

Are these correct?

What do I have to do to get SourceTree to use my git in c:\Git\cmd\git.exe ?

 

1 answer

In Tools\Options\Git the button is greyed out because it is using the system Git, not the embedded one. It should really be a radio button.

Not sure how you could make it use the system Git, but a quick workaround is to set SourceTree to use the embedded Git instead of the 1.5.6.4.

That is not a viable option. I work in a highly regulated environment and all the developers need to use the same tools, including the same git version.

I added a .sh file to c:\cygwin\etc\profile.d to alter my path to put c:\Git\cmd first. This fixed the git version used if a bring up a terminal with SourceTree, but a git clone is still using the original cygwin version, ignoring my path. Why is SourceTree so obsessed with my cygwin installation anyway? And why can't I tell it explicitly what git.exe I want it to use? I finally tried the incredible hack of renaming my cygwin git.exe to something else, then from an elevated prompt I linked c:\cygwin\bin\git.exe to my mysysgit.exe at c:\Git\cmd\git.exe. This is a rediculous hack and dangerous, there are many other git-related exe files in my cygwin installation and I only faked out one. But it did at last allow me to clone a repository. I want a solution where I can tell SourceTree where my git.exe is located.

I seem to have finally solved this, but I'm not sure how. I restored the cygwin git.exe so that SourceTree could find it if it really wanted to. I left the profile.d changes in place. I had found the following file on my system: C:\Users\<me>\AppData\Local\Atlassian\SourceTree.exe_Url_<stuff>\1.5.2.0\user.config There is an entry in it "GitSystemPath" that had value C:\Git I changed the value to C:\Git\cmd Then when I brought up SourceTree, the version was correct everywhere I looked; no more usage of cygwin's git. I closed SourceTree and looked at the user.config file again and the value had reverted back to C:\Git But when I brought up SourceTree again, it was still using the correct git version. So somehow I had nudged it in the right direction. The above may be a total red herring.

Just want to add to Laura's point: you must have cmd subfolder with git.exe in the path set by  "GitSystemPath" key in the user.config file1.

I had MSYS2 installed and with `git.exe` at `usr/bin` folder, so after I've pointed to this git.exe during installation and whenever I tried to manually adjust that user.config path, nothing worked. However, when I symlinkd usr/bin to usr/cmd it all worked out just fine!

This is a very bad design when the system instead of the using git.exe the user already pointed to just assumes some path setup it thinks is correct (and not even recording it in the user.config files!!!).

 

1 (the one at `C:\Users\<Username>\AppData\Atlassian\SourceTree.exe_Url_<stuff>\<latest version, might be several folders>\user.config`

 

P.S.

This https://answers.atlassian.com/questions/14210401 led me to this idea, although there it's the opposite suggestion — they want to symlink and existing bin folder to cmd smile

P.P.S.

And yeah, changing the path value in user.config doesn't persist (and may not matter at all). While trying to figure out why the app crashed when launching terminal, changed path manually to a local copy of Atlassian git, but it reverted back to the system git I had before.

However, changing my PATH environment variable to include the new custom folder BEFORE others along with changing user.config did the trick — it no longer reverted the change (so now it's clear that this part of user.config is irrelevant since it's just taken from the first git.exe found in PATH).

Suggest an answer

Log in or Join to answer
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

231 views 0 3
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot