0

I just reinstalled mountain lion and seem to have lost git in the process. I tried following this post : Why is Git not found after installing OS X Lion? but although I can cd into /usr/local/git I get /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/binwhen I echo $PATH

How can I change the path so I can go back to using git? Sorry if this is an obvious question, I'm fairly new to git/terminal commands.

Update:

I tried as suggested in another post and it seems to be working again:

sudo -s
mkdir -p /usr/local/bin
ln -s /usr/local/git/bin/git /usr/local/bin/git
exit
4
  • See anlr's answer there
    – mmmmmm
    Jul 26 '13 at 13:16
  • I looked at that but was a bit hesitant as I have Mountain Lion and not Lion.
    – mantis
    Jul 26 '13 at 13:22
  • Oh nevermind I got it confused with another answer I found that specifically mentions Lion. It works fine. I guess I should erase this question as it was already answered?
    – mantis
    Jul 26 '13 at 13:42
  • in this case leave it as it will be closed as a duplicate but will help others searching e.g. if they search for mountain lion.
    – mmmmmm
    Jul 26 '13 at 14:24
0

Touch your .bash_profile to create it if you have none:

touch ~/.bash_profile

Now, add this line to the above file at the end of the file:

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

Then, run this in the terminal

source ~/.bash_profile
0
0

You can add it to your .bash_profile as another answer suggests, but the install should create a file in /etc/paths.d to add it to users' paths:

$ ls -l /etc/paths.d/git
-rw-r--r--  1 root  wheel  19 Sep 17  2009 /etc/paths.d/git
$ cat /etc/paths.d/git
/usr/local/git/bin

If you don't have that, you can do this:

sudo bash -c '( echo /usr/local/git/bin > /etc/paths.d/git )'

Personally I don't like path entries for every little package, so I would symlink the contents of /usr/local/git/bin into another bin dir.

3
  • Thanks for your answer. I've already got it working though. I was trying to run the above commands anyway but am wary of breaking something that currently works ;) So if I understand correctly this would change the path per package?
    – mantis
    Jul 27 '13 at 9:16
  • It would add "/usr/local/git/bin" to the system default path. At login, it includes any paths defined in text files within /etc/paths.d/ directory. So what software installers are supposed to do, instead of modifying user's .bashrc files, is to create a text file in that directory with the bin directory to be added to the path. If you look, you probably have others you can use as an example. I have 5 or so, some starting with numbers (to make them appear sooner in the PATH) and some do not. And you don't have to use echo as I show. You can just sudo to root and use a text editor to create it.
    – Tim B
    Jul 27 '13 at 15:56
  • I seem to have made a right mess of things and somehow my bash_profile settings are no longer recognised. I am getting unknown-00-26-bb-0e-a8-1f:~ mantismamita$ as my prompt instead of the usual. (mantismamita is my username)
    – mantis
    Aug 4 '13 at 9:15

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