Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am trying to install Git on my Mac (OSX 10.6) following the official Git tutorial.

I had no problem until I had to set my username and my email.

Every time I tried I got "-bash: git: command not found"

I tried echo 'export PATH=/usr/local/git/bin:$PATH' >> ~/.profile + restarted the Terminal. It still doesn't work.

What do you thik sould I do to solve the problem?

I've never used the OSX GIT installer before and don't really want to.

Edit 1: the command issue is fixed

Edit 2: the result of the command /usr/bin/grep PATH .* is

.bash_history:echo 'export PATH=/usr/local/git/bin:$PATH' >> ~/.profile
.bash_history:echo $PATH
.bash_history:echo $PATH
.bash_history:echo 'export PATH=/usr/local/git/bin:$PATH' >> ~/.profile
.bash_history:echo $PATH
.bash_history:echo 'export PATH=/usr/local/git/bin
.bash_history::$PATH' >> ~/.profile
.bash_history:echo 'export PATH=/usr/local/git/bin
.bash_history:echo 'export PATH=/usr/local/git/bin
.bash_history:echo 'export PATH=/usr/local/git/bin
.bash_history::$PATH' >> ~/.profile
.bash_history:echo 'export PATH=/usr/local/git/bin:$PATH' >> ~/.profile
.bash_history:echo $PATH
.bash_history:echo 'export PATH=/usr/local/git/bin:$PATH' >> ~/.profile
.bash_history:echo $PATH
.bash_history:echo $PATH
.bash_history:echo $PATH
.profile:export PATH=/usr/local/git/bin:$PATH
.profile:export PATH=/usr/local/git/bin:$PATH
.profile:export PATH=/usr/local/git/bin:$PATH
.profile:export PATH=/usr/local/git/bin:$PATH
.profile:export PATH=/usr/local/git/bin:$PATH
.profile:export PATH=/usr/local/git/bin:$PATH

Edit 3 : if you encounter the same problem here is the solution

I edited the .profile file like this :

export PATH=/usr/local/git/bin:/usr/local/git/bin:/usr/local/git/bin:$PATH

It seems to work again.

Conclusion: be very cautious when editing the .profile file.

share|improve this question
1  
Why don't you want to use the installer? –  rightfold May 4 '11 at 16:03
    
Even if you don't want to use the installer, you may still consider using a package manager like homebrew, which will certainly make installing, uninstalling, and updating much, much easier: github.com/mxcl/homebrew –  michaelmichael May 4 '11 at 17:49
    
thanks for your answers. But the installler/package manager part of my question is not my main concern. –  politicus May 4 '11 at 18:02
    
Glad you got it working - but just a note on the PATH you've got above, you've gotten the same directory listed in the PATH three times - it will work, but it is only needed once. To explain, what the PATH variable does - when you type a command in terminal - each directory listed in the PATH is searched in order for the command you ran. Each directory is separated by colon character. A handy tip too - before you edit any system file, you can make a quick copy of it (cp .profile .profile.bak) that way you can easily revert to a working version if something breaks. –  barryj May 5 '11 at 8:52
add comment

1 Answer 1

up vote 1 down vote accepted

Where did you install git to? Different install methods will put it in different places. Double check your install process. On my machine i have it in /usr/bin/

You need to ensure your PATH contains the directory that the git lives in.

You can either run 'locate git' to search for it, you'll probably have to build your locate database if you haven't already.

Of you can just try a few typical places

/usr/bin/git --version

Once you know where it is installed, can modify your PATH file by editing .profile or .bash_profile to add the appropriate value.

share|improve this answer
    
Thanks for your answer. I installed Git in /usr/local/git/bin and I allready tried to add it to my path. Now I can only use the cd command. ls, git ... commands don't work anymore. –  politicus May 4 '11 at 17:43
    
OK - that's an unusual place to install it - are you sure? Are you sure you didn't install it in: /usr/local/bin ? Have a check in the various directories to see where it actually is. Then verify that it works by running it with a full path: e.g. /usr/local/bin/git OR /usr/local/git/bin/git OR /usr/bin/git etc. Once you have the correct path and you know it works, modify your PATH variable to be the 'directory' where the git executable lives. –  barryj May 4 '11 at 18:07
    
I am sure it is the rigth directory. The git file located in this directory, when launched, list the most common git commands. In PATH I have /usr/local/git/bin:/usr/local/git/bin:/usr/local/git/bin .My problem is I can't use any terminal commands except cd ,-( –  politicus May 4 '11 at 18:48
    
OK well that's probably because you've messed up your PATH. Some of the basic commands are built-in to the shell so don't rely on a PATH. One of the commands you've used has obliterated your shell path. Edit the contents of .profile and fix that. If you want help try posting the contents of this command: /usr/bin/grep PATH .* –  barryj May 4 '11 at 19:14
    
The git .dmg install does put git in /usr/local/bin/git so it is the normal place and not a problem- but as noted show us what your .profile/ full PATH is –  Mark May 4 '11 at 23:42
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.