3

I want to use latest version of git (1.8.3).

Currently when I make git --version it shows me git version 1.7.12.4 (Apple Git-37) which was installed together with Xcode I suppose.

I installed newest version but still bash uses Xcode one..

Please advice me how to override xcode git with the path that is installed to usr/local/bin?

Thanks!

Kosmetika
  • 20,774
  • 37
  • 108
  • 172

2 Answers2

7

Edit ~/.bash_profile and add

alias git=/usr/local/bin/git

Source the bash_profile file or restart bash (source ~/.bash_profile)

See what git --version prints. I am not sure if this affects XCode. I never use versioning tools in IDEs, I do it from the command line

Or you add /usr/local/bin to $PATH to your bash_profile. I do this with macports or better said macports alters your bash_profile automatically.

export PATH=/usr/local/bin:$PATH
Christian Rapp
  • 1,853
  • 24
  • 37
  • yeah, it works fine but I thought there could be another way with adding to $PATH, isn't it? – Kosmetika May 28 '13 at 09:48
  • Yup see my updated answer, should also work instead of the alias. – Christian Rapp May 28 '13 at 09:52
  • Changing the $PATH in bash_profile won't work for Xcode as it isn't launched from a terminal session. You'll need to set the environment variables differently, eg see http://stackoverflow.com/questions/6770411/mac-os-x-lion-no-longer-recognizes-environment-plist – the_mandrill May 28 '13 at 12:22
  • Kosmetika did "git --version" in a shell. My answer will work in this case. I told him it might not work in XCode. – Christian Rapp May 28 '13 at 13:34
  • 2
    For what it's worth, the file you need to edit if you're using ZSH instead of BASH is ~/.zshrc (YMMV based on your configuration). –  Jul 19 '14 at 05:43
  • yes but the ask was to replace xcode's git -- as I understood it -- anyway :) k – Daij-Djan Mar 05 '15 at 12:44
1

Use a symbolic link to make Xcode use the /usr/local/bin/git instead of its built-in git

cd /Applications/Xcode.app/Contents/Developer/usr/bin/
sudo mv git xcodeGIt
sudo ln -s git /usr/local/git

Disclaimer: typed inline -- but thats how it works. Done it and it works fine for me

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
  • maybe (depending on what you need) you also want to ln -s the following: git-receive-pack git-upload-archive git-cvsserver git-shell git-upload-pack – Daij-Djan May 28 '13 at 12:52