{infiniteZest}
// Articles. Tutorials. Utilities.
Home  |   Search  |   Login  
Categories Skip Navigation Links
New / All
AJAX
Apple
ASP.NET
.NET
Git
Google / Android
Python / IronPython
Miscellaneous
SQL Server
Finding, installing Git on Mac
Summary
By default, git is available on the Mountain Lion. However, it is not added to the path. This article also discusses getting the git via Command Line Tools.
 
Table of Contents

Where is Git on Mountain Lion?

Adding Git to the Path

Adding Git from the Xcode Command Line Tools

Figure 1. Downloading Command Line Tools from Xcode

Git from git-scm site

 

Where is Git on Mountain Lion?

By default, git is installed on Mountain Lion in the following directory:

/usr/local/git/bin/

Adding Git to the Path

By default, the above directory is not added to the path. It can be added to the path with the following line:

export PATH=${PATH}:/usr/local/git/bin/

Add that to PATH. And that should let you access git.

For the above to work from Terminal, add the above line to the .bash_profile.

The .bash_profile file is in the HOME directory:

$ cd ~

Listing the .bash files:

ls .bash*

.bash_history .bash_profile

Add/change the .bash_profile file to include the above line:

$ vi .bash_profile

The version of git installed here might be different from the version you install via the Command Line Tools of Xcode.

Following was the default git version (when Mountain Lion was first installed):

$ cd /usr/local/git/bin

$ ./git --version

git version 1.7.3.1

When using git, you might also get the following error:

Can’t locate SVN/Core.pm in @INC (@INC contains: /usr/local/git/lib/perl5/site_perl /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.4 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library/Perl/Extras/5.12 .) at /usr/local/git/libexec/git-core/git-svn line 41.

You can resolve the Perl location errors. Or, installing the Command Line Tools from Xcode (as shown below) will also fix the issue.

Adding Git from the Xcode Command Line Tools

Git can also be installed by installing the Command Line Tools from Xcode. This can be done from Preferences dialog box (Downloads section):

Figure 1. Downloading Command Line Tools from Xcode

Figure 1. Downloading Command Line Tools from Xcode

Installing the Command Line Tools will put git in /usr/bin directory. As you can see below this version is different. Depending on when you install, this version number will be different.

$ cd /usr/bin

$ ls -la git

-rwxr-xr-x 2 root wheel 2680896 Aug 7 20:28 git

$ ./git --version

git version 1.7.9.6 (Apple Git-31.1)

Git from git-scm site

You can also download from the git official site itself. That site will, of course, have the latest git version:

http://git-scm.com

The actual download packages for various operating systems (Mac, Windows, Linux, etc.) are here:

http://git-scm.com/download

You can also download git source from here:

$ git clone https://github.com/git/git.git

Bookmark and Share This

More Articles With Similar Tags
icon-svn-to-git.jpg
Tags: git, svn, subversion
This article talks about migrating a repository from SVN to Git one way – meaning, after the migration, the project is expected to be developed only in Git. It also talks about the cleanup of the migrated Git repository.
This article talks about the important aspects of migrating a repository from Subversion (SVN) to Git Version Control System.
This article talks about the steps involved in pushing a newly migrated Git repository to a server location.
This series of articles explains migrating Subversion repositories into Git.
About  Contact  Privacy Policy  Site Map