Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

override git from Xcode with homebrew version

I've installed XCode and therefore git is there as well. Since i want to have a newer version of git I installed using homebrew.

But the homebrew version of git is never called since my PATH looks like this

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin 

which means the /usr/bin/git is allways called before /usr/local/bin/git.

Is there a way to change that without changing the PATH?

like image 502
BetaRide Avatar asked May 04 '12 13:05

BetaRide


People also ask

Is Git included in Xcode?

Xcode will create your new project along with a new Git repository. All source control systems, including Git, store their data into a repository so that they can manage your project versions and keep track of changes throughout the development cycle. Think of a repository as a database for versions.


1 Answers

Xcode is actually using the GIT that is stored in /Applications/Xcode.app/Contents/Developer/usr/bin. The same version of GIT gets installed in /usr/bin when you installed the command line tools as part of Xcode installation. So, you won't be able to change what Xcode is using (unless you are willing to muck with the contents of the Xcode package). If, from a terminal application, you want to use the homebrew-installed GIT then you have two options:

  1. Reference GIT with the full path as /usr/local/bin/git ... For this case you can create an alias like alias mgit=/usr/local/bin/git and then use mgit ... from the terminal
  2. Change the path as PATH=/usr/local/bin:$PATH either in your .bashrc or .zshrc if you use zsh file (or each time you start a terminal at the command line).
like image 192
GoZoner Avatar answered Sep 22 '22 17:09

GoZoner