转自http://www.flatws.cn/article/program/python/2011-06-06/29177.html
在Ubuntu 10.04上配置gitosis作为git服务器的操作步骤
在服务器端<server>
#安装所需软件
ubuntu@<server>:~$ sudo apt-get install git-core openssh-server openssh-client
#将git数据保存在/data/repo目录下
ubuntu@<server>:~$ sudo mkdir /data/repo
#使用git用户作为服务器端管理用户
ubuntu@<server>:~$ sudo useradd -m git
ubuntu@<server>:~$ sudo passwd git
#只有git用户有权限
ubuntu@<server>:~$ sudo chown git:git /data/repo
ubuntu@<server>:~$ sudo chmod 700 /data/repo
#配置全局信息
ubuntu@<server>:~$ git config --global user.name "<user name> git server"
ubuntu@<server>:~$ git config --global user.email "<email>"
#安装gitosis
ubuntu@<server>:~$ sudo apt-get install python-setuptools
ubuntu@<server>:~$ cd /tmp
ubuntu@<server>:/tmp$ git clone git://eagain.net/gitosis.git
ubuntu@<server>:/tmp$ cd gitosis
ubuntu@<server>:/tmp/gitosis$ sudo python setup.py install
#链接/data/repo 到 /home/git/repositories
ubuntu@<server>:/tmp/gitosis$ su git
$ ln -s /data/repo /home/git/repositories
$ exit
在客户端<pc1>,将本地的公钥拷到服务器上
<pc1>:~ admin$ scp .ssh/id_dsa.pub git@<server>:/tmp
在服务器端<server>
#让gitosis运行起来
ubuntu@<server>:/tmp/gitosis$ sudo chmod a+r /tmp/id_dsa.pub
ubuntu@<server>:/tmp/gitosis$ sudo -H -u git gitosis-init < /tmp/id_dsa.pub
#如果没有设置过root密码,则设置一下,否则跳过
ubuntu@<server>:/tmp/gitosis$ sudo passwd root
#进去看一眼
ubuntu@<server>:/tmp/gitosis$ su
root@<server>:/tmp/gitosis# cd /home/git/repositories
root@<server>:/home/git/repositories# cd gitosis-admin.git/
root@<server>:/home/git/repositories/gitosis-admin.git# ls
branches description gitosis-export hooks info refs
config gitosis.conf HEAD index objects
root@<server>:/home/git/repositories/gitosis-admin.git# sudo chmod 755 /data/repo/gitosis-admin.git/hooks/post-update
root@<server>:/home/git/repositories/gitosis-admin.git# exit
#创建一个测试项目teamwork.git
ubuntu@<server>:/tmp/gitosis$ su - git
$ cd /data/repo
$ mkdir teamwork.git
$ cd teamwork.git
$ git init --bare
$ exit
在客户端<pc1>
#git权限管理本身也是通过一个git仓库来管理的, 将gitosis-admin.git复制clone下来
<pc1>:projects admin$ git clone git@<server>:gitosis-admin.git
<pc1>:repo admin$ cd gitosis-admin/
#将别的用户<pc2>的pub公钥加进来, 我是把它先copy到~/Downloads/下了
<pc1>:gitosis-admin admin$ cp ~/Downloads/id_rsa.pub ./keydir/<user2@pc2>.pub
#修改权限配置
<pc1>:gitosis-admin admin$ vim gitosis.conf
----------------------------------------
[gitosis]
[group gitosis-admin]
writable = gitosis-admin
members = ubuntu@server user1@pc1
[group hello]
writable = teamwork
members = user1@pc1 user2@pc2
------------------------------------------
<pc1>:gitosis-admin admin$ git add .
<pc1>:gitosis-admin admin$ git commit -a -m "add my netbook user"
<pc1>:gitosis-admin admin$ git push origin master
<pc1>:repo admin$ mkdir teamwork-ori
<pc1>:repo admin$ cd teamwork-ori/
<pc1>:teamwork-ori admin$ git init
<pc1>:teamwork-ori admin$ vim README
<pc1>:teamwork-ori admin$ git add .
<pc1>:teamwork-ori admin$ git commit -a -m "initial version"
<pc1>:teamwork-ori admin$ git remote add origin git@<server>:teamwork.git
<pc1>:teamwork-ori admin$ git push origin master
然后从pc2的机器上,也就clone下来git仓库来使用了,很棒!
注意,中间如果遇到这样的错误,很可能是gitosis.conf配置的不对
ERROR:gitosis.serve.main:Repository read access denied
fatal: The remote end hung up unexpectedly
有可能是:
1. gitosis 中写的用户名,和keydir里面的key的名字没有完全对应上
2. 有的地方写错了,比如我把members写成了member,汗
[补充]:
1. 默认remote为master的配置方法:
$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master
分享到:
相关推荐
ubuntu10.04界面汉化安装包,deb格式。由于包的相互依赖,需用如下命令安装: #dpkg -i language-pack-zh-hans_1%3a10.04+20100421_all.deb language-pack-zh-hans-base_1%3a10.04+20100421_all.deb language-pack-...
VM7安装Ubuntu 10.04系统 VM7安装Ubuntu 10.04系统
Ubuntu 10.04完全版入门教程 包含Ubuntu安装,配置过程,以及shell编程等内容。 分两部分: Ubuntu 10.04完全版first part Ubuntu 10.04完全版second part
ubuntu10.04 安装 opencv2.2.0
介绍最新版本Ubuntu10.04的安装,配置,shell编程等内容,快速入门提高的资料。 分两卷: Ubuntu10.04入门教程01 Ubuntu10.04入门教程02
ubuntu10.04下android开发环境搭建指南
官方的chrome 只支持12.04以上的版本,由于所需的库不同 ubuntu 10.04 只能用之前的版本
Ubuntu 10.04 搭建vsftpd 2.2.2
最近开始学习Linux操作系统,遇到了很多问题,走了不少弯路。 Linux的却比windows强大很多,但像我这样刚入门的,用起来却不那么顺手。就拿上网来说吧,我在网上查了...此方法只适用于Ubuntu10.04,低版本我没试过。
Ubuntu 10.04下Android编译环境搭建
主要介绍了关于嵌入式开发的环境配置 开发环境是Ubuntu 10.04LTS
4月29日最新发布的Ubuntu10.04正式版,是有一个LTS长期支持的版本。
安装Ubuntu10.04全过程(图解)
ubuntu10.04安装配置指南.docx
家里的老笔记本装了诸多新版Ubuntu均不稳定,最终还是装回了10.04,结果安装最新版的方式得到的最新版本已经不能兼容10.04了。于是上网找了Chrome稳定版本的历史版本,然后本地下载各种版本尝试安装,得到了最新可...
UBuntu 10.04 smb.conf UBuntu 10.04 smb.conf UBuntu 10.04 smb.conf UBuntu 10.04 smb.conf
一步一步教你如何子啊VM下安-ubuntu10.04的详细图文教程
少点分,这个是在别人的基础上得来的。只好弄少点分了。欢迎大家下载
ubuntu10.04能用的NFS离线安装包:nfs-kernel-server 1.2.0;nfs-commn1.2.0;portmap 6.0
ubuntu10.04北京交通大学的更新源,我这能飙到450K/s