一、git安装(服务器端操作)
这个很简单,获取源码包然后编辑安装就OK
1、下载软件包
http://www.kernel.org/pub/software/scm/git/
2、安装
#./configure --prefix=/usr/local/git
#make
#sudo make install
#git --version
#vi /etc/profile
#export PATH=/usr/local/git/bin:/usr/local/git/libexec/git-core:$PATH
二、gitosis安装(服务器端操作)
方法一:
#yum install gitosis 自动安装好
方法二:
#yum -y install python-setuptools
#git clone git://eagain.net/gitosis.git
#cd gitosis
#python setup.py install
备注:GIT设置安装路径会导致clone出现诡异错误,默认路径安装解决
三、配置使用
1、创建git 帐号(服务器端操作)
#adduser git
#passwd git
2、生成公钥、密钥(LINUX客户端操作)
$ssh-keygen -t rsa (会在HOME/.ssh下生成公钥密钥)
3、上传.ssh里的公钥:xxx.pub 到服务器端(任何地方均可)
4、服务器端操作(记得切换到git用户)
$gitosis-init < xxx.pub(上一步上传地址)
$chmod 755 /home/git
$chmod 700 /home/git/.ssh
$chmod 644 /home/git/.ssh/authorized_keys
$chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update (重要,要不gitosis-admin的配置无法生效)
So your friend Bob wants to help you out with myNewProject. Have Bob generate his own id_rsa.pub and send it you. When you have it:
cd gitosis-admin
Assuming Bob's id_rsa.pub is in your home directory, move it to the key directory renaming it at the same time:
mv ~/id_rsa.pub keydir/bob.pub
Tell git about the new file:
git add keydir/bob.pub
Edit your gitosis.conf file again. Look for the members line in myNewProject and add Bob to it:
members = user@someServer.com bob
Now you could add bob to be in the gitosis-admin group if you wanted him to be able to do what you're doing now. How much do you trust Bob?
Save the file and quit. It's time to tell your server about Bob and send Bob's public key.
git commit -a -m "Added commit rights to Bob on myNewProject"
git push
The server will automatically add Bob's public key to authorized_keys. Do not attempt to add him manually.
注:
1、window下 git客户端使用方法
下载个git for win(http://code.google.com/p/msysgit/)安装
启动git bask(操作基本跟linux下一样)
公钥密钥可以直接在linux上生成,然后下来过来使用(跟linux一样是放在当前用户根目录.ssh下(如:C:/Documents and Settings/Administrator/.ssh)
2、公钥密钥从window下上传需要转格式(可参考下linux下生成的格式)
3、.ssh/下的密钥名称为id_rsa不能更改这个名称(不确定能不能更改,刚试了下其它名称是不行的)上传到服务器的公钥可以更改名称