开心人生

用今天的努力----实现我所向往的明天

导航

MacBook OSX10.6下 git 的安装

以下方法转自官网:http://help.github.com/mac-git-installation/

Installing git (OSX)

There are a number of methods to install git on OSX. This guide details the most common methods, in order of ease of install.

After you have completed installation you will need to generate an SSH keypair and set your local git config.

Pre-compiled Installer

Download and run git-osx-installer

Homebrew

  1. Install Homebrew if you haven’t already done so.
  2. Install Git (You may want to include Subversion support if you want to import SVN repositories. Snow Leopard already contains a copy of SVN)
$ brew install git
==> Downloading http://kernel.org/pub/software/scm/git/git-1.6.5.7.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/git/1.6.5.7
==> make install
==> Downloading http://kernel.org/pub/software/scm/git/git-manpages-1.6.5.7.tar.bz2
######################################################################## 100.0%
/usr/local/Cellar/git/1.6.5.7: 383 files, 16M, built in 74 seconds

MacPorts

  1. Install MacPorts if you haven’t already done so.
  2. Make sure your ports are up to date.
  3. Install Git (You may want to include Subversion support if you want to import SVN repositories)
$ sudo port selfupdate

MacPorts base version 1.600 installed
Downloaded MacPorts base version 1.600

The MacPorts installation is not outdated and so was not updated
selfupdate done!

$ sudo port install git-core +svn
--->  Installing curl 7.18.2_0
--->  Activating curl 7.18.2_0
--->  Installing openssh 5.0p1_0+darwin_9
--->  Activating openssh 5.0p1_0+darwin_9
--->  Installing p5-error 0.17012_0
--->  Activating p5-error 0.17012_0
--->  Installing popt 1.13_0
--->  Activating popt 1.13_0
--->  Installing rsync 3.0.2_0
--->  Activating rsync 3.0.2_0
--->  Installing git-core 1.5.5.3_0+doc
--->  Activating git-core 1.5.5.3_0+doc

Compiling git manually

See this guide.

自己心得:

在Git for OS X下使用git本来应该很简单,github guide上介绍了3种在osx上使用git的方法:

  1. 下载并安装git-osx-installer
  2. 使用macports安装git
  3. 从git的原代码安装

不过第一种方法只支持leopard,如果你用的还是tiger的话就要考虑后面的方法了,按照完之后,要重新打开一个终端才能使用git

第二种方法在使用macports安装git的时候居然提示缺少perl的运行环境什么的错误,第三种方法也需要下载mac下的编译工具,实在是太麻烦了,于是还是借助google搜索了已经在tiger上编译好的git安装包git-1.5.4.3-1.mpkg,安装完成后最好在终端运行环境(.bashrc)中加入git的地址以便下次直接可以运行git的命令:

export PATH=$PATH:/usr/local/bin
export MANPATH=`manpath`:/usr/local/man

posted on 2010-07-14 10:03  hai  阅读(1350)  评论(0编辑  收藏  举报