views:

340

answers:

2

I have MacPorts' Git at /opt/local/bin/git, while the newest Git at /opt/local/git.

My PATH command

export PATH=/usr/local/git:/opt/local/bin:/opt/local/sbin:/Users/Masi/.cabal/bin:/Users/Masi/.cabal/bin/xmonad:$PATH

The command

echo $PATH

gives me

/usr/local/git:/opt/local/bin:/opt/local/sbin:Users/Masi/.cabal/bin:/Users/Sam/.cabal/bin/xmonad:/sw/bin:/sw/sbin:$PATH:/opt/local/bin:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/bin/perl::/usr/X11R6/bin

I run the following command and get MacPorts' Git

which git
/opt/local/bin/git

Aaron says

Add /opt/local/git as the first element in the path, then /opt/local/bin/. This way, your git will be found, first, and everything else from `/opt/local/bin/ will be available, too.

I did not get the newest Git to be run although I have it first in my PATH.

How can you change Git to be loaded from the second PATH?

+2  A: 

Two solutions:

  1. Add /opt/local/git as the first element in the path, then /opt/local/bin/. This way, your git will be found, first, and everything else from `/opt/local/bin/ will be available, too.

  2. Create a new bin/ directory somewhere, create soft links (ln -s) for all programs which you need in there and then but that bin/ as the first thing into your path.

Aaron Digulla
The problem solved. I had a wrong folder in my PATH. It should be /usr/local/git/bin. --- Thank you for your answer!
Masi
+3  A: 

You shouldn't put binaries in /opt/local. Unless there's a particular reason you need an older version of git, you shouldn't have two copies installed. Leave the /opt hierarchy for macports. If you want to build a software package on your own, install it into /usr/local. This would put the git binary in /usr/local/bin. Whichever of /usr/local/bin and /opt/local/bin is first in $PATH, files in that directory will take precedence.

outis