您的位置:首页 > 其它

GIT粗游记(一)

2014-02-28 14:23 162 查看


开篇

用SVN已渐显疲感,于是今天突来兴致便拿GIT一试,粗游一番。按照个人习惯,本编便以搭建GIT服务器为起点,逐篇游玩GIT各处亮点。


初始环境

服务器:CentOS 6.3

使用SSH远程登录服务器后,安装GIT相关依赖包:

[root@economy ~]# yum install curl curl-devel zlib-devel perl perl-devel gettext-devel expat-devel openssl-devel -y


安装GIT

以下将介绍两种安装方式(看客自行二选一):

①、使用命令“yum”安装默认镜像版本(一般安装版本较低)

[root@economy ~]# yum install git
...
[root@economy ~]# git --version
git version 1.7.1

②、通过源码编译安装最新版本

(地址不能翻墙可下载ZIP包:https://github.com/git/git/archive/master.zip)

[root@economy ~]# cd /usr/src
[root@economy src]# wget https://git-core.googlecode.com/files/git-1.9.0.tar.gz ...
[root@economy src]# ls
git-1.9.0.tar.gz
[root@economy src]# tar -zxvf git-1.9.0.tar.gz
...
[root@economy src]# cd git-1.9.0
[root@economy git-1.9.0]# make configure
[root@economy git-1.9.0]# ./configure --prefix=/usr/local
...
[root@economy git-1.9.0]# make all
...
[root@economy git-1.9.0]# make install
...
[root@economy git-1.9.0]# git --version
git version 1.9.0


安装GITOLITE(用于管理GIT服务器)

安装GITOLITE相关依赖包:

[root@economy git-1.9.0]# yum install perl-Time-HiRes -y

创建GIT用户:

[root@economy git-1.9.0]# useradd git
[root@economy git-1.9.0]# passwd git
...
[root@economy git-1.9.0]# su - git
[git@economy ~]$

通过GIT安装最新版本:

[git@economy ~]$ git clone git://github.com/sitaramc/gitolite
...
[git@economy ~]$ mkdir bin
[git@economy ~]$ ls
bin  gitolite
[git@economy ~]$ ./gitolite/install -to ~/bin/
[git@economy ~]$ ls bin
commands  gitolite  gitolite-shell  lib  syntactic-sugar  triggers  VERSION  VREF

安装管理员SSH秘钥(管理员xxx@xxx.xxx看客自行修改):

[git@economy ~]$ ssh-keygen -C xxx@xxx.xxx
Generating public/private rsa key pair.
Enter file in which to save the key (/home/git/.ssh/id_rsa): xxx@xxx.xxx
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in xxx@xxx.xxx.
Your public key has been saved in <span style="font-family: Arial, Helvetica, sans-serif;">xxx@xxx.xxx</span><span style="font-family: Arial, Helvetica, sans-serif;">.pub.</span>
...
[git@economy ~]$ ls
bin  gitolite  xxx@xxx.xxx  xxx@xxx.xxx.pub
[git@economy ~]$ gitolite setup -pk xxx@xxx.xxx.pub
...
[git@economy ~]$ ls .ssh
authorized_keys


收尾

服务器的搭建可以说就此完成,下回粗游GITOLITE如何管理GIT服务器。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息