git

一、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的配置无法生效)

5、客户端操作
$git clone git@serviceIp:gitosis-admin.git   (有可能会需要按yes进入下一步)
$cd gitosis-admin
编辑gitosis.conf添加如下测试组
[group myteam]
writable = newProject
members = 先设置为跟gitosis-admin用户组一样方便测试
$git commit -a -m 'Allow the user xxx write access to newProject'
$git push(上传到服务器,生效)
创建新项目(客户端操作)
$cd ..
$mkdir newProject
$cd newProject
$git init
$git remote add origin git@serviceIp:newProject.git(如果提示已经存在则先执行git remote rm origin)
随便在目录里放些内容(一定要做)比如
$touch README
$git add .
$git commit -a -m 'This is my initial commit for newProject'
$git push origin master:refs/heads/master
OK,到此您就有一个自己的GIT服务器了

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不能更改这个名称(不确定能不能更改,刚试了下其它名称是不行的)上传到服务器的公钥可以更改名称

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值