27

When trying to use some of the commands from the Git bundle for TextMate (eg. 'Show Uncommited Changes') I get an error message like 'sh: line 1: git: command not found'.

How do I make TextMate work with Git?

Will Harris
  • 21,597
  • 12
  • 64
  • 64

6 Answers6

49

http://theappleblog.com/2008/01/09/textmate-no-longer-a-reason-to-avoid-git/

Set the TM_GIT shell variable in the textmate preferences to your git executable to work to solve the command not found problem.

To find the path to your git binary, type "which git" on the command line. And of course, make sure Git is installed.

John Millikin
  • 197,344
  • 39
  • 212
  • 226
  • PS: for some reason, my colleague did not run into this problem on Snow Leopard, worked out of the box. – mxk Oct 19 '09 at 09:23
  • This doesn't work for me in Snow Leopard. When I try to run "sh git" on the command line, I get this error: /usr/local/git/bin/git: /usr/local/git/bin/git: cannot execute binary file – Radamanthus Dec 13 '09 at 02:33
  • 3
    It looks like the explanation for this is that in TM `Settings -> Advanced -> Shell Variables` there is a (pointless?) default PATH of "/usr/bin:/bin:/usr/sbin:/sbin", so even if you have asked GitInstaller to add git to the path, TextMate would skip it :-/ – conny Nov 19 '10 at 15:45
  • @conny You are right! Under Settings -> Advanced -> Shell Variables I had to add the TM_GIT variable with the path /usr/local/git/bin/git AND uncheck the PATH "/usr/bin:/bin:/usr/sbin:/sbin" variable in order to get the bundle to work. I'm on Snow Leopard. – sarahjean Apr 29 '11 at 14:49
3

If you already allowed git-osx-installer to make git available to non-CLI applications (i.e. it planted a file in /etc/paths.d/git) then you could just..:

Untick the PATH shell variable set by default in the textmate preferences. 
conny
  • 9,973
  • 6
  • 38
  • 47
2

I recently run in the same problem with Snow Leopard, and none of the above solutions was apperaring to be working. So I made a symlink in /usr/bin to my git executable file like this:

cd /usr/bin

sudo ln -s `which git` git

then relaunched Textmate and it worked like a charm, without adding any variable or whatever

Kevin
  • 4,618
  • 3
  • 38
  • 61
spaghetticode
  • 343
  • 3
  • 7
1

Also, once you add the TM_GIT var, restart TextMate. Didn't work for me after the preference change without a restart.

0

@Radamanthus You shouldn't run "sh git" from your commandline. You should run "git" directly. Also, you should use the which command (run "which git") to get a path to your git binary (as mentioned by @John Millikin).

Peter Theill
  • 3,117
  • 2
  • 27
  • 29
0

Add the location of your git to the PATH shell variable in TextMate > Preferences... > Advanced > Shell Variables.

Blake Taylor
  • 9,217
  • 5
  • 38
  • 41