公司开发人员越来越多,每次合代码都会出现很多问题,而且代码的越来越多,占用很大空间,迁移和备份浪费人力和时间。有开发人员提出使用git来管理代码,个人在网上查看了一些关于git的资料。发现git的很多优点,具体大伙去网上搜索下。
一、安装git服务
yum -y install zlib-devel openssl-devel perl cpio expat-devel gettext-devel gcc autoconf perl-ExtUtils-MakeMaker package perl-Time-HiRes perl-Time-HiRes gcc
gcc-c++ make zlib-devel zlib perl-ExtUtils-MakeMaker
package perl-devel perl-CPAN
下载git源码包
[root@localhost ~]#cd /usr/local/src
[root@localhost src]#useradd git 添加git用户,统一由git管理,绝对禁止使用root。
[root@localhost src]# tar -zxvf git-1.9.0.tar.gz
[root@localhost src]# cd git-1.9.0
[root@localhost git-1.9.0]# autoconf
[root@localhost git-1.9.0]# ./configure --with-curl=/usr/local
[root@localhost git-1.9.0]#make && make install
[root@localhost git-1.9.0]#cd /data/
[root@localhost data]#chown git:git /data 个人习惯,将所有应用放到/data下
[root@localhost data]#su - git切换用户
二、安装gitolite权限管理插件
[git@localhost data]$.mkdir -p /data/git/bin/gitolite/share/gitolite/conf /data/git/bin/gitolite/share/gitolite/hooks
[git@localhost src]$.sed -i 's/GL_PACKAGE_CONF=/usr/share/gitolite/conf/GL_PACKAGE_CONF=/data/git/bin/gitolite/share/gitolite/conf/' /data/git/bin/gitolite/gl-setup
[git@localhost src]$../gl-system-install /data/git/bin/gitolite/ /data/git/bin/gitolite/share/gitolite/conf/ /data/git/bin/gitolite/share/gitolite/hooks/
[git@localhost gitolite]$./gl-setup ~/admin.pub
将下面两行修改为自己创建的目录
$GL_PACKAGE_CONF = "/usr/share/gitolite/conf";
$GL_PACKAGE_HOOKS = "/usr/share/gitolite/hooks";
修改为
$GL_PACKAGE_CONF = "/data/git/bin/gitolite/share/gitolite/conf";
$GL_PACKAGE_HOOKS = "/data/git/bin/gitolite/share/gitolite/hooks";
cd gitolite-admin/
添加新版本库
vim conf/gitolite.conf
repo iyiji
RW+ = @admin
R = @all
git add conf/gitolite.conf 跟踪修改文件
git commit -m "add iyiji"提交修改文件
git push
提交到git服务器
添加新用户:
将用户的key放到/data/gitolite-admin/keydir
git add keydir
git commit -m "add iyiji"
git push