网上大牛都说的是安装gitolite要建git用户,我看完全没必要,毕竟用户拿到私钥也未必能登录服务器吧。。。下面我们就用root用户来安装gitolite,并且配置版本库文件保存路径。。
1. gitolite安装涉及到几个目录:
/data/gitolite #git文件保存路径
/data/gitolite/bin #git安装文件保存路径
gitolite管理用户rsa公钥:git.pub
2. ### server requirements
* any unix system
* sh
* git 1.6.6 or later
* perl 5.8.8 or later
* openssh 5.0 or later
3. 从github上获取最新gitolite版本
[[email protected] /data/tmp]# git clone git://github.com/sitaramc/gitolite Cloning into ‘gitolite‘... remote: Counting objects: 8682, done. remote: Total 8682 (delta 0), reused 0 (delta 0) Receiving objects: 100% (8682/8682), 3.61 MiB | 533.00 KiB/s, done. Resolving deltas: 100% (4917/4917), done. Checking connectivity... done.
4. 安装gitolite到/data/gitolite
[[email protected] /data/gitolite]$ mkdir bin [[email protected] /data/tmp/gitolite]$ ./install -to /data/gitolite/bin [[email protected] /data/gitolite/bin]$ ./gitolite setup -pk /root/.ssh/GitAdmin.pub Initialized empty Git repository in /data/gitolite/repositories/gitolite-admin.git/ Initialized empty Git repository in /data/gitolite/repositories/testing.git/ WARNING: /home/forilen/.ssh/authorized_keys missing; creating a new one (this is normal on a brand new install)
修改~/.gitolite.rc,修改repositories 存放路径,注意:.gitolite的路径不能改,否则提交的新用户无法clone,因为提交的公钥无法添加到authorised_keys中,
LOG_EXTRA => 1,
GL_REPO_BASE => "/data/gitolite/repositories",
移.gitolite repositories到/data/gitdata
5. 在git.pub所属服务器上clone获得gitolite权限配置文件
[email protected]192.168.100.252:/data/forilen/git# git clone [email protected]192.168.100.245:gitolite-admin Initialized empty Git repository in /data/forilen/git/gitolite-admin/.git/ WARNING: Can‘t exec "git": No such file or directory at /home/forilen/bin/lib/Gitolite/Common.pm line 146, <DATA> line 1. fatal: The remote end hung up unexpectedly [email protected]192.168.100.252:/data/forilen/git# git clone [email protected]192.168.100.245:gitolite-admin Initialized empty Git repository in /data/forilen/git/gitolite-admin/.git/ remote: Counting objects: 6, done. remote: Compressing objects: 100% (4/4), done. remote: Total 6 (delta 0), reused 0 (delta 0) Receiving objects: 100% (6/6), done. [[email protected] bin]# ln -sf /data/usr/git/bin/git git [[email protected] bin]# which git /usr/bin/git #git在git服务器上的唯一路径 [[email protected] bin]$ ./gitolite setup -pk ../.ssh/key252.pub Initialized empty Git repository in /home/forilen/repositories/gitolite-admin.git/ Initialized empty Git repository in /home/forilen/repositories/testing.git/ WARNING: /home/forilen/.ssh/authorized_keys missing; creating a new one (this is normal on a brand new install) root@192.168.100.252:/data/forilen/git# git clone [email protected]192.168.100.245:gitolite-admin Initialized empty Git repository in /data/forilen/git/gitolite-admin/.git/ remote: Counting objects: 6, done. remote: Compressing objects: 100% (4/4), done. remote: Total 6 (delta 0), reused 0 (delta 0) Receiving objects: 100% (6/6), done. [email protected]192.168.100.252:/data/forilen/git# ls gitolite-admin [email protected]192.168.100.252:/data/forilen/git# tree . . └── gitolite-admin ├── conf │ └── gitolite.conf └── keydir └── key252.pub 3 directories, 2 files
6. Git客户端配置
6.1 Windows上git客户端软件安装
内网资源:ftp://192.168.100.252/tools/
mysysGit:默认安装,点next下去
TortoiseGit:默认安装,点next下去
6.2 密钥对生成及配置
6.2.1 在启动栏找到gitbash
6.2.2 运行gitbash,生成密钥对
6.2.3 启动栏启动Puttygen
6.2.4 导入1.2 生成的私钥
弹出警告,点【确定】
6.2.5 生成tty格式公钥
6.2.6 提交公钥给git服务器管理员
6.2.7 生成的id_rsa.pub重命名为 英文名.pub
7. 本地clone版本库
确认管理员把权限和帐号都配置完成后,才能导出版本库到本地
7.1 本地建立空目录,右键 git clone
7.2 选择导出目录
7.3 Git相关操作
8. 常见问题解决方法
8.1 本地密钥管理机
8.1 打开导入新的密钥
9. 其他:
hook: http://www.tuicool.com/articles/Z7by2y
10. 参考文献:
http://www.ossxp.com/doc/git/gitolite.html#id3
http://www.ossxp.com/doc/git/gitolite.html