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

How to properly direct SourceTree to use Git in the Git for Windows SDK?

Eric Anderson September 26, 2017

Most Git users on Windows are probably using Git for Windows.
https://git-for-windows.github.io/

That great application is built upon the Git for Windows SDK.  Optionally, instead of just installing Git for Windows, one may install the Git for Windows SDK, which also provides the MSYS2+MinGW Linux build environment integrated with Windows.
https://github.com/git-for-windows/build-extra/releases/latest

It seems that when installing SourceTree, it now has trouble finding or recognizing how to use Git when it is located in an install of the Git for Windows SDK.  (This did not seem to be a problem in the past.  I've been using the older versions of SourceTree with the GfW SDK for a very long while before now.)

I have two related questions about getting the new SourceTree to properly use Git from the Git for Windows SDK.

1) Sometimes during installation SourceTree admits it doesn't recognize where Git is on the system.  So it asks where it is.  The proper response is not clear.  Even supposing it wants to know where git.exe is, which of the following possibilities might be the one most appropriate for SourceTree's need?

C:\git-sdk-64\cmd\git.exe
C:\git-sdk-64\mingw64\bin\git.exe
C:\git-sdk-64\mingw64\libexec\git-core\git.exe
C:\git-sdk-64\usr\bin\git.exe
C:\git-sdk-64\usr\lib\git-core\git.exe
C:\git-sdk-64\usr\src\git\git.exe

2) Since I had been observing fragile behavior and failures on startup for the new SourceTree, I thought I would try making a different selection than I did previously.  However, at the moment, after the latest reinstall of SourceTree, it seems to just assume I'm using system Git that is "LibGit2Sharp" (an interface to libgit2 for Visual Studio .NET)!  I see no way to tell it that I want to point it to a different location of Git.  Is there any way at all in the SourceTree Tools / Options for Git to say, "Let me point you to Git"?  I see only the options of Embedded or else the choice it's made of LibGit2Sharp.

p.s. I'm trying to use SourceTreeSetup-2.3.1.0.exe, which I downloaded fresh from https://www.sourcetreeapp.com/ just to be sure it was the very latest.

p.p.s. Regarding my first question, I will point out that the git.exe applications in these two locations are currently binary identical.

C:\git-sdk-64\mingw64\bin\git.exe
C:\git-sdk-64\mingw64\libexec\git-core\git.exe

Likewise, these two applications are also binary identical with each other (but different from the previous two).

C:\git-sdk-64\usr\bin\git.exe
C:\git-sdk-64\usr\lib\git-core\git.exe

(The other two applications in the list of six are each unique.
C:\git-sdk-64\cmd\git.exe is by far the smallest and
C:\git-sdk-64\usr\src\git\git.exe is by far the largest.
)

Yet, even if two choices are identical files, I do not know whether or not there are unexpected ramifications of choosing one or the other.  As far as I know, even when two copies of an application are identical, there still might be different implications for choosing one or the other, for example, if SourceTree expects certain other files to be present in the same directory as the git.exe application it wants to know about.

1 answer

1 accepted

1 vote
Answer accepted
minnsey
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 2, 2017

Hi

So the short answer is we don't formally support that style of Git install, we have a similar arms length approach to Cygwin installs of Git.

However this information may be of use to you and others.

Sourcetree expects to use the cmd/git.exe version of git.exe.
When Sourcetree starts it tries to find a system install of git by looking for a git.exe in

  • the PATH
  • known install folders in c:\program files*\

If it can't find a system git install it will, depending on situation, download and install an embedded copy or prompt the user to manually find the git.exe.

Because the user might find bin/git.exe or one of the others, when Sourcetree is presented with a git.exe it will attempt to walk the local folder structure to find cmd/git.exe

If it does it checks the git version and if all is good it will configure itself to use and remember that Git install.

So, provided the SDK folder structure mirrors that of  Git for Windows release, if you point Sourcetree at C:\git-sdk-64\cmd\git.exe it should use it.

Sourcetree should accept any 1.x or 2.x version of Git.

 

 

I hope this helps.

Eric Anderson October 2, 2017

"This is a very helpful answer.  Thank you!  ..."

FYI: After I first wrote this reply, I made some small edits.  But after I Published the changed version, the whole reply disappeared from view when I would refresh the page, just as if I had not made any Reply at all.

So I made another Reply with the same content.  Now I see that both versions are finally appearing simultaneously.  Therefore, I am leaving the more complete one in place (see below) and editing this earlier version to alert you to a problem with Publish of an edited Reply.  I realize that issue is a separate matter, but I'm at least explaining what happened.

Eric Anderson October 2, 2017

This is a very helpful answer.  Thank you!  It does clearly answer the first of my two questions.

Regarding my remaining question, you made this statement.

"If it can't find a system git install it will, depending on situation, download and install an embedded copy or prompt the user to manually find the git.exe."

In my early experience of installing the latest version, it did prompt me "to manually find the git.exe."  However, not knowing what you just clarified (thank you), I believe I picked the wrong git.exe.

Now when I reinstall SourceTree it isn't giving me that prompt or the opportunity to make a better pick of git.exe.

That leads to my second question.  Is there any way at all (e.g. in the SourceTree Tools / Options for Git or any other way) to tell SourceTree, "Let me point you to Git"?"

If there isn't any such option now, is there a work around that can force the prompt to occur?

For the future I would suggest as a feature request that there should be a "Let me manually select cmd/git.exe" option.  I can understand there might be reasons you are not (yet?) supporting automatic detection of these alternate installations of Git.  But if so, then I think it would be reasonable to help the users easily be successful in manually finding not just any git.exe, but the cmd/git.exe that SourceTree expects.

Thanks again for your response!

p.s. There is another reason such a feature is needed.  As I indicated, sometimes SourceTree may make a poor choice, such when it chose LibGit2Sharp.  To overrule a poor choice, it would be valuable to be able to say, "Let me show you where cmd/git.exe really is."

minnsey
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 3, 2017

Hi

Yes the community.atlassian.com site has the occasional niggle' :)

in ST 2.3.1.0 you should be able to go into the Tools/Options/Git tab and do the following

  1. switch to embedded git, this might involve downloading git.
  2. use the 'clear path cache' option
  3. use the 'use system git' option.
    1. Provided Git isn't found on your PATH or in the standard install locations, which I don't think it will be for you, you should be promoted to browse.

Ultimately this will get written into the %localappdata%/Atlassian/Sourcetree.exe_url_{hash}/2.3.1.0/user.config

You can, with Sourcetree closed, edit this to set Sourcetree to use a system git

 

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

And then tell it where to find it

<setting name="GitSystemPath" serializeAs="String">
     
<value>C:\projects\dvcses\PortableGit-2.8.1-32bit</value>
</setting>

 

restart Sourcetree and, provided it can successfully run 'cmd/git.exe version'  it should run that version of git.

Like # people like this
Eric Anderson October 3, 2017

Thank you!

1. I did switch to Use Embedded Git.

2. The button to Clear path cache never became enabled, so I didn't use it.

3. I did select Use System Git.  With the vital help you provided above of now knowing I needed to find and use the cmd version of git.exe, I did select that version this time (not the bin version I believe I picked earlier).

The immediate result, even without restarting Sourcetree, is that Sourcetree was once again enabled to open/load my repositories without the errors I was experiencing.  Great!

I am now persuaded that the issue from the start was that I made the wrong selection when I picked a git.exe (probably the one under the bin directory).

Consequently, I think it would be very helpful, whenever Sourcetree prompts for finding git.exe, if it could mention at least a good hint related to cmd.  For example, instead of saying something like "Pick/Select git.exe" it might say "Pick/Select the cmd version of git.exe".  That would be a trivial software change to the prompt string, but even that little clue about which version to pick would be better than no guidance at all.

Thanks again for these helpful answers!

Like Sandeep Shukla likes this
Eric Anderson October 4, 2017

p.s. Actually, I'm still having some problems with Sourcetree crashing.  I've put the information in this issue.

https://jira.atlassian.com/browse/SRCTREEWIN-7964

Sandeep Shukla February 11, 2020

Thank you !! @minnsey  @Eric Anderson reading your question/answers finally I was able to resolve the issue !!!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events