Chinaunix首页 | 论坛 | 博客
  • 博客访问: 495567
  • 博文数量: 112
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 662
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-20 07:22
个人简介

一步一个脚印

文章分类

全部博文(112)

文章存档

2019年(2)

2017年(2)

2016年(2)

2015年(6)

2014年(35)

2013年(65)

分类: LINUX

2013-02-24 23:22:49

在服务器(CentOs)上首先安装git软件

yum install git

添加用户git


useradd -r -s /bin/sh -c 'git version control' -d /home/git git

passwd git  #添加密码

设置权限


mkdir -p /home/git

chown git:git /home/git

客户机准备工作

Windows7客户机上安装msysgit   TortoiseGit   Gypwin

运行msysgit 下的git bash

ssh-keygen -t rsa  生成的pub公钥位于C:\Users\用户名\.ssh下面的id_rsa.pub

cd .ssh

scp id_rsa.pub git@server_ip:/tmp  #上传公钥到服务器上tmp目录下

服务器端操作

su git

git clone git://github.com/ossxp-com/gitolite.git   #下载最新gitolite安装程序

cd gitolite/src/

./gl-system-install

PATH=/home/git/bin:$PATH

 

exit  #回到root用户下

mkdir -p /usr/share/gitolite/conf/ 

cp /home/git/share/gitolite/conf/example.gitolite.rc /usr/share/gitolite/conf/

#把默认gitolite-admin管理库的配置模板拷贝到程序查找的一个目录

 

su git

cd /home/git/bin

./gl-setup /tmp/id_rsa.pub

 

cd /home/git/repositories/gitolite-admin.git/hooks

rm -rf post-update   #程序生成的是错误链接post-update,删除重建

ln -s /home/git/share/gitolite/hooks/common/post-update post-update

注:post-update出错会引起修改gitolite.conf生成新的仓库不生效。

 /home/git/repositories/gitolite-admin.git/hooks下的

post-update

post-receive.mirrorpush

update

是gitolite很关键的钩子程序,在客户端管理员修改配置文件push到服务器时,能够即时触发脚本执行相应操作


Linux系统、苹果系统作为客户端管理员第一次连接服务器的时候使用ssh方式clonegitolite-admin仓库时,碰到总是要输入密码的情况,

经过研究,这与ssh验证有关,最好不要改公钥的名字,否则需要改ssh配置文件/etc/ssh/ssh_config里的私钥名称

IdentityFile ~/.ssh/id_rsa        IdentityFile ~/.ssh/id_dsa 


Git服务器配置好了以后

客户端管理员是基本不用登陆服务器就能完成所有操作。

git clone git@server_ip:gitolite-admin.git

在本地生成gitolite-admin管理库

修改conf/ gitolite.conf配置文件  增加仓库,增加用户,修改权限等等。

repo    testing2
        RW+CD                     = @admin
将其他客户端的公钥id_rsa.pub文件拷贝至keydir文件夹下

git add .      git commit –m”message”      git push  

成功会有类似提示

remote: Already on 'master'

remote: creating testing2...

remote: Initialized empty Git repository in /home/git/repositories/testing2.git/

 

git clone git@server_ip:testing2

将生成的新仓库克隆到本地

创建文件、修改,然后

git add .    git commit –m”message”   git push  

会提示错误:

No refs in common and none specified; doing nothing.

Perhaps you should specify a branch such as 'master'.

fatal: The remote end hung up unexpectedly

error: failed to push some refs to 'root@192.168.1.225:testing.git'

 

这是因为没有指定分支,使用下面命令

git push origin master

 

以后就好了

  

用Ubuntu操作系统做Git服务器的时候,也会碰到找不到配置文件、软链接指定文件异常的情况,也可以借鉴我的解决办法。

  

苹果操作系统教程-Git客户端使用



阅读(2022) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~