Source Tree is not using correct system Git

I've installed Source Tree and set it up to use system Git. However, it shows that the Git is version, but if execute:

git --version

I get:

git version

Perhaps, this is because I'm using Macports' Git and not the git distributed with Mac OS.

3 answers

1 accepted

0 votes
Answer accepted

Yeah, this happens in 1.2 because SourceTree picks the first git it finds (and can't know what your PATH is). In 1.3, which is in beta now and will be released soon, when you click 'Use System Git' SourceTree prompts you with a browse dialog so you can point it elsewhere from the one SourceTree detects if you want.

I realize this is a fairly old thread, but I can't find a more recent one and this doesn't seem to work (Sourcetree

I'm running Mac OSX 10.8.4, which came preloaded with Git, (Apple Git-37), located in /usr/bin. I wanted to take advantage of some new features in Git 1.8.2+, so I installed the latest version into /usr/local/git/bin and had Sourcetree use the system git at that location. I also updated ~/.MacOSX/environment.plist to prepend that to the default path (which as I understand it will allow non-terminal applications to search there first for any executables).

However, after all this some of my custom actions were not working because the git they used didn't have these new features. To test I created a simple custom action that only ran "git --version": it still returned the Apple-supplied version. When I renamed the git exectuable in /usr/bin the action failed completely because it couldn't find a git executable.

It *seems* to me that Sourcetree is explicitly executing custom-action git related commands using executables found in /usr/bin, and not actually relying on the PATH to find the first one available. Unless I hear otherwise, I will file a bug, as this doesn't seem like it's the intended behavior when you explicitly choose the system git executable.

For now, I've found the workaround to be manually placing a symlink in /usr/bin pointing to my /usr/local/git/bin/git executable

We actually can't control everything in your custom actions, if you're using a script which is using bash then it's likely that it's overriding the PATH it has inherited from SourceTree (e.g. in .profile). All SourceTree can do is call it within its own environment, if it changes the PATH after that, that's out of our control.

That makes sense. However, I tried my best to make sure that the location of the new git executable would be available to all Apps. I am semi-new to MacOSX, so I may have gotten something wrong.

The new git is in /usr/local/git/bin. I have prepended that to my PATH in ~/.bash_profile (via sourcing ~/.bashrc, which actually does the exporting), which I understand only affects my bash shells, not Apps. I also added it to the default PATH in ~/.MacOSX/environment.plist. To verify, I get

Barrett$ echo $PATH

Barrett$ defaults read ~/.MacOSX/environment
>>>    PATH = "/usr/local/git/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/sur/X11/bin:/opt/local/bin";

which looks like it's setup correctly. However, when I create a Custom Action which calls "printenv" I get


Is there some other place I need to add the path in order for SourceTree to include it in the shell it creates for custom actions? You mentioned .profile in particular, which I didn't have. But, after adding it with the same PATH exports (via sourcing my .bashrc, if that makes a difference), I still see the same PATH from the SourceTree custom action shell.



PS: Is there a better place for this discussion?

Recent versions of OS X no longer respect the contents of environment.plist, sadly - you'll need to use launchd.conf instead:

Well, that would explain it...

Thanks a bunch for the help.


What happens when you run which git from the commandline. Is the output the same as the git you set up in sourcetree?

@Colin Goudie

In my case not. Sourcertree says System Git version (pointed it to the (show package content -> Content -> Developer -> usr -> libexec -> git-core ->git)).

Terminal says git version (Apple Git-33) (git --version).

Dont know why or how.

Running 'which git' on the command line will probably show your terminal is using an older version from somewhere else.

Hi Steve, Should i echo 'export PATH=/usr/local/git/bin:$PATH' >> ~/.profile? Also i have got a folder named git in the Home directory. Is this a other version of git than the Apple xCode one? Thanks for your time and effort.

What I would personally do is point your system git in SourceTree to wherever 'which git' points on the command line, which is usually '/usr/local/git/bin/git' (this should be the default anyway).

As for editing your profile, yes if your PATH doesn't already include /usr/local/git/bin then that would do it. That's usually configured for you though when you get a command-line version of git (either from or by installing the command line tools from inside Xcode from Preferences > Downloads).

Hi Steve, Thanks for your help and answer. I will point Source Tree to the Usr/local/... Have a nice day, in my part of the world the sun is shyning at the moment. I hope it will for you to.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

1,214 views 4 2
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