码迷,mamicode.com
首页 > 其他好文 > 详细

gitolite 服务器搭建

时间:2015-01-22 12:51:18      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:

网上大牛都说的是安装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版本
[root@servertwiki /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
[git@servertwiki /data/gitolite]$ mkdir bin
[git@servertwiki /data/tmp/gitolite]$ ./install -to /data/gitolite/bin
[git@servertwiki /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权限配置文件
root@192.168.100.252:/data/forilen/git# git clone forilen@192.168.100.245:gitolite-admin
Initialized empty Git repository in /data/forilen/git/gitolite-admin/.git/
WARNING: Cant 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
root@192.168.100.252:/data/forilen/git# git clone forilen@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.
 
[root@servertwiki bin]# ln -sf /data/usr/git/bin/git git
[root@servertwiki bin]# which git
/usr/bin/git #git在git服务器上的唯一路径
[forilen@servertwiki 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 forilen@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.
root@192.168.100.252:/data/forilen/git# ls
gitolite-admin
root@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   

http://sharadchhetri.com/2013/06/01/how-to-install-own-git-server-with-ssh-and-http-access-by-using-gitolite-and-gitweb-in-centos/

10. 参考文献:

http://www.ossxp.com/doc/git/gitolite.html#id3

gitolite 服务器搭建

标签:

原文地址:http://www.cnblogs.com/forilen/p/4241055.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!