Git Community Book翻译 (四)
Git Community Book 第一章还有一部分没有译完,因为有些内容我现在还译不好,我这里就把( 三 ) 这个编号留下来,先译后面的的内容。
第二章
First time
安装Git
Unix从源代码开始安装
如果你在一个其基于Unix的系统中,你可以从Git的官网上下载它的源代码,并运行像下面的几行命令,你就可以安装。
$ make prefix=/usr all ;# as yourself
$ make prefix=/usr install ;# as root
你需一些库:expat,curl,zlib和openssl; 除了expat 外,其它的可能在你的机器上都安装了。
Linux
如果你用的是Linux,你可以用你的本地包管理系统(native package management system)来安装。
$ yum install git-core #译者注,在redhat等系统下用yum
$ apt-get install git-core #译者注,在debian, ubuntu等系统下用apt-get
如果你用上面的命令不起作用的话,你可以从下面两个站点下载 .deb 或 .rpm 包:
RPM Packages http://kernel.org/pub/software/scm/git/RPMS/
Stable Debs http://www.backports.org/debian/pool/main/g/git-core/s
如果你在Linux兴趣从源代码开始安装的话,下面的这篇文章也许对你有帮助:
Installing Git on Ubuntu http://chrisolsen.org/2008/03/10/installing-git-on-ubuntu/
Mac 10.4
在Mac10.4和 10.5,如果你安装了MacPorts,你可以通过它来安装Git。如果你没有安装MacPort, 你可以从这里来安装它: http://www.macports.org/install.php
当你安装好MacPorts后,你可通过下面的命令来安装:
$ sudo port install git-core
如果你想从源代码开始安装,下面这些文章可能对你有帮助:
Article: Installing Git on Tiger Linux
http://rails.wincent.com/wiki/Installing_Git_1.5.2.3_on_Mac_OS_X_Tiger
Mac10.5
在Leopard系统下,你也可以通过MacPorts来安装,但是你有一个新的选项:using a nice installer, 你可以从这里来下载:http://code.google.com/p/git-osx-installer/downloads/list?can=3
如果你想从源代码开始安装,我希望下面些资料能对你有帮助:
Article: Installing Git on OSX Leopard
http://solutions.treypiepmeier.com/2008/02/25/installing-git-on-os-x-leopard/
Article: Installing Git on OS 10.5
http://dysinger.net/2007/12/30/installing-git-on-mac-os-x-105-leopard/
Winodws
在Windows下安装Git是很简单的,你只要下载msysGit 包(http://code.google.com/p/msysgit/downloads/list)就可以了。
See the Git on Windows chapter for a screencast demonstrating installing and using Git on Windows.
安装与初始化
git config
使用Git的第一件事就是设置你的名字和email,这些就是你在提交commit时的签名。
$ git config --global user.name "Scott Chacon"
$ git config --global user.email "[email protected]"
执行了上面的命令后,会在你的主目录(home directory)建立一个叫 “.gitconfig” 的文件。
内容一般像下面这样:
[user]
name = Scott Chacon
email = [email protected]
如果你要针对不同的项目设置一个特定的值(例如把私人邮箱地址改为工作邮箱),你可以在项目中使用git config 命令来设置(不带—global 选项)。这会在你项目目录下的 “.git/config” 文件增加一个节[user]内容(如上所示).