Reputation: 141160
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?
Upvotes: 1
Views: 2088
Reputation: 77400
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.
Upvotes: 3
Reputation: 328594
Two solutions:
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.
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.
Upvotes: 2