Install Git separately from Xcode

11,860

Solution 1

Xcode installs git in /Applications/Xcode.app/... but if you run 'Install Command Tools' then git gets installed also in /usr/bin/git. Xcode uses its private version in Xcode.app. If you installed git in /usr/local/git/bin then you need to include that directory in your PATH. You should have a .bashrc file (or equivalent for whatever shell you are using). Add

PATH=/usr/local/git/bin:$PATH     # your shell might use different syntax.

to that file 'rc' file.

Also, note that Xcode would allow you to accomplish your goal of setting up a remote at home while maintaining a local copy on your laptop. Go to the Xcode 'organizer' and click 'repositories'. There you will find all your machine's Git repositories. Choose one, select the 'remotes' folder and then '+' to add your home remote. I use Xcode this way.

Solution 2

Credits goes to @GoZoner for the answer. I'm just summing up everything.

Download official git installer from : http://git-scm.com/download/mac

Install and add its directory to your path : echo "PATH=/usr/local/git/bin:\$PATH" >> ~/.bash_profile source ~/.bash_profile

Share:
11,860
Chris Sanderson
Author by

Chris Sanderson

Updated on August 01, 2022

Comments

  • Chris Sanderson
    Chris Sanderson over 1 year

    Firstly apologies if this is a really simple question but Git is absolutely brand new to me. Basically I've been dabbling with a bit of iOS development for a little while and now have a project idea that I want to start working on and for the first time I'm planning on putting this into source control.

    Now I know Xcode 4 has some Git integration but I've spotted a couple of posts that suggest the integration isn't that great and it's better to do it the command line way.

    So, I've been following instructions here http://git-scm.com/book/en/Getting-Started-Installing-Git and I've downloaded version 1.7.10.3 for Mac and ran the install.

    However when I run git --version I get version 1.7.4.4 which is the version that was installed with Xcode I assume?

    My question is, how do I make use of my new version 1.7.10.3? The plan is to learn to use Git via command tools and set up a central repository on a server I have at home, then have local copies on my laptop.

    As I say I'm really new to this, so a quick step by step idiots guide would be helpful. I have searched and tried to find details here and on google but other than the suggestion to use Git outside of Xcode I've not found out exactly how to do it.

    Any advice, or links to a decent tutorial that covers this would be very much appreciated.

    Update:

    I've changed the path to the new path in .bash_profile (/usr/local/git/bin) and now get git version 1.7.7.5 (Apple Git-26). This still appears to be the wrong version (although this could be me being dense). I downloaded the installer for OSX from the above link. Should I be doing something else. I want to play around with the command line tools so I can get a proper understanding

    Update 2:

    I'm now also trying MacPorts as recommended in the article. This seems to be downloading a lot more than just Git though