Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Git separately from Xcode

Tags:

git

xcode

macos

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

like image 240
Chris Sanderson Avatar asked Jun 05 '12 20:06

Chris Sanderson


People also ask

Does Xcode include Git?

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.

How do I download Git on Mac using Xcode?

Install Git Using XcodeIts command-line tools include Git in the package. The output should display the latest Git release, as in the example below. If you do not have Git, it automatically asks you whether you want to install it. Confirm the installation, and Xcode sets up Git.

How do I manually install Git?

To install Git, navigate to your command prompt shell and run the following command: sudo dnf install git-all . Once the command output has completed, you can verify the installation by typing: git version .


2 Answers

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.

like image 102
GoZoner Avatar answered Oct 01 '22 23:10

GoZoner


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

like image 38
Daishi Avatar answered Sep 29 '22 23:09

Daishi