0

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 think I should 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
5
  • 1
    Why don't you want to use the installer?
    – user235
    May 4, 2011 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 May 4, 2011 at 17:49
  • thanks for your answers. But the installler/package manager part of my question is not my main concern.
    – politicus
    May 4, 2011 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, 2011 at 8:52
  • I've rolled back your edit which added the solution to the question because this tends to confuse people. You've accepted an answer below so future visitors will know what to do to resolve similar issues. If you want to add details, either edit the answer or leave a comment.
    – nohillside
    Mar 23, 2015 at 15:54

3 Answers 3

1

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.

7
  • 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, 2011 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, 2011 at 18:07
  • 1
    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, 2011 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, 2011 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
    – mmmmmm
    May 4, 2011 at 23:42
1

This should get you going:

We need to make sure the Terminal goes through the correct order of folders to discover your newer version of Git.

$ echo "export PATH=/usr/local/git/bin:/usr/local/bin:/usr/local/sbin:$PATH" >> ~/.bash_profile

Tell the Terminal to look at your bash_profile to get the updated order of folders (your "$PATH")

$ source ~/.bash_profile

Now let's check your Git version again

$ git --version
1

In the event that my following answer breaks your normal Terminal commands, as it did to me. I found another solution that works better.

If you used my last post to set the PATH for Git, and you no longer have access to commands such as

cd ls

The first thing to do is run

unset PATH

export PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

Then run

touch ~/.bash_profile
open ~/.bash_profile

And add the following line to your .bash_profile file

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

Save the file and back in Terminal run

source ~/.bash_profile

To update the .bash_profile file inside the running Terminal session

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .