Updating Git on Mac
I have previously installed Git (1.9.3) and I want to update to the latest version (2.0.1). I removed the previous installation by running uninstall.sh first and then git.pkg. However, when I run git --version
, it still shows me git version 1.9.3 (Apple Git-50)
.
So, I did this:
$ which git
/usr/bin/git
$ echo $PATH
...:/usr/local/git/bin
Obviously, the Git in / usr / local / git / bin is the latest version I want.
So how can I remove the path of the older version and tell Mac OSX where to find the version you want?
Thank!
One solution would simply change the order in yours $PATH
in yours~/.bash_profile
export PATH=/usr/local/git/bin/:$PATH
source ~/.bash_profile
As indicated in the git: command not found (in OS X 10.5) , and locate the installer folder Git on the X OS the Mac .
In your case, you have /usr/local/git/bin/
in PATH
, but in the wrong order, if you want it to be taken into account.
Xcode uses its own version of git, which makes it a bit tricky to update. These two terminal commands worked for me:
sudo mv /usr/bin/git /usr/bin/git-xcode
sudo ln -sf /usr/local/git/bin/git /usr/bin/git
This solution is taken from Heroku's recently posted security warning for git 1.9.3. This post includes a download link . These two commands are recommended in this link. The .dmg download package also contains a README file with a similar link .
A pre-installed version of Git comes with OSX and I used that after seeing that this version has some underlying security issues. I went ahead and downloaded the latest Git from the Git site, but even after installation, when I looked at it in the terminal with the Git --version command, it showed me an older one.
So I googled a little and found out that
These vulnerability issues were addressed in the beta release of Xcode, as stated in this official statement from Apple.
http://support.apple.com/en-us/HT204147
So guys went and downloaded the beta version of Xcode. If you are comfortable using apples Git like me.
Good luck!