{{ v.name }}
{{ v.cls }}类
{{ v.price }} ¥{{ v.price }}
在git服务管理工具这个领域,主要有三种流行的方案,它们分别是
gitosis-轻量级,开源项目,使用ssh公钥认证,只能做到库级的权限控制。目前项目已经停止开发,不再维护。
gitolite-轻量级,开源项目,使用ssh公钥认证,能做到分支级的权限控制。
git+repo+gerrit-超级重量级,集版本控制,库管理和代码审核为一身。可管理大型及超大型项目。
大名鼎鼎的android平台就是使用的git+repo+gerrit。对于个人,中小型企业及一些开源项目而言,如果没有特殊的要求,其实没有必要去架设上面第三种方案git服务器。gitolite提供的服务已经足够用。下面将详细讲解怎么搭建gitolite服务器。
gitolite的安装需要分别在客户端和服务器端操作。搭建gitolite的步骤如图所示在ubuntu12.04lts上搭建gitolite服务器的详细步骤,假设客户端和服务器端已经安装好了git。如果还没有安装git,请分别在客户端和服务器端运行下面的命令安装git。
$sudoapt-getinstallgit
$ssh-keygen-trsa-chf
这里注意,为了区分sshpublickey,请将sshpublickey重命名,最好是用用户名命名。例如.pub
$mv/home/ubuntuusers/hf/.ssh/id_rsa.pubhf.pub
$scphf.pubhf@ubuntu-12.04-lts:/tmp
$sudoadduser
>--system
>--shell/bin/bash
>--gecos'gitscmuser'
>--group
>--disabled-password
>--home/home/gitgit
$sudosugit
$cd$home
$gitclonehttp://github.com/sitaramc/gitolite
$mkdir-p${home}/bin
$${home}/gitolite/install-to${home}/bin
$${home}/bin/gitolitesetup-pk/tmp/hf.pub
$gitclonegit@ubuntu-12.04-lts:gitolite-admin.git
conf/gitolite.conf用于git项目配置,访问权限设置。
keydir/用于存储用户的sshpublickey(公钥)。
为了增加git项目到gitolite服务器,有两种方法:
修改gitolite.conf
例如,新建一个名为foo的git项目,首先你需要在conf/gitolite.conf里注册foo项目。假设你已经克隆了gitolite-admin.git项目,编辑conf/gitolite.conf,增加下面的内容【3】。
repofoo
rw+=@all
设置git项目
hf@ubuntu-12.04-lts:~$mkdirfoo
hf@ubuntu-12.04-lts:~$cdfoo
hf@ubuntu-12.04-lts:~/foo$gitinit
initializedemptygitrepositoryin/home/ubuntuusers/hf/foo/.git/
hf@ubuntu-12.04-lts:~/foo(master)$gitremoteaddoriginhf@ubuntu-12.04-lts.git
hf@ubuntu-12.04-lts:~/foo(master)$touchreadme
hf@ubuntu-12.04-lts:~/foo(master)$gitaddreadme
hf@ubuntu-12.04-lts:~/foo(master)$gitcommit-m"initialcommit"
[master(root-commit)997d5d8]initialcommit
0fileschanged,0insertions(+),0deletions(-)
createmode100644readme
hf@ubuntu-12.04-lts:~/foo(master)$gitpushoriginmaster:refs/heads/master
countingobjects:3,done.
writingobjects:100%(3/3),217bytes,done.
total3(delta0),reused0(delta0)
tohf@ubuntu-12.04-lts:foo.git
*[newbranch]master->master
hf@ubuntu-12.04-lts:~$gitclonehf@ubuntu-12.04-lts:foo.git
cloninginto'foo'...
remote:countingobjects:3,done.
remote:total3(delta0),reused0(delta0)
receivingobjects:100%(3/3),done.
如果你有一个已经存在的项目,也想将其添加到gitolite的服务器里。这很简单,但是首先你依然需要在gitolite.conf里注册这个项目。然后执行下面的操作:
cdfoo
gitremotermorigin
gitremoteaddoriginhf@ubuntu-12.04-lts.foo.git
gitpushoriginmaster
gitpushorigin