3 answers

1 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 1.6.2.2).

I'm running Mac OSX 10.8.4, which came preloaded with Git, 1.7.12.4 (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 1.7.12.4 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

You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.

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.

You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.

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

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

PATH=/usr/bin:/bin:/usr/sbin:/sbin

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.

Thanks,

-Barrett

PS: Is there a better place for this discussion?

You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.

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.

You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.

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 git-scm.com or by installing the command line tools from inside Xcode from Preferences > Downloads).

You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.