11.默认状态下,gitosis会将git仓库放在 gitadmin用户的home下,所以我们做一个链接到/home/repo
ln -s /home/git/repo /home/gitadmin/repositories
返回正常用户:
$ exit
light-server@lightserver-GREATWALL-PC:~$
查看软链接状态:
12.如果你将作为git服务器的管理员,那么在你的电 脑上(另一台pc)生成ssh公钥:
我在我的电脑上,用户为:wuzhang@ubuntu:$
生成ssh公钥。
wuzhang@ubuntu~:$ ssh -keygen -t rsa
OK,生成公钥成功!
复制到远程主机上,这就考验我们Linux 命令的基础了。还好大一linux学的还不错!
Scp 远程复制命令: scp 本地文件 远端主机:存储路径
例如:scp .ssh/id_rsa.pub light-server@10.255.13.253:/tmp
OK,100%这个我喜欢, 说明复制成功了,不信我们可以去主机查看:
果然有id_rsa.pub.
在git服务器上,更改权限:
git@lightserver-GREATWALL-PC:/tmp/gitosis$ sudo chmod a+r /tmp/id_rsa.pub
13.让gitosis运行起来:
执行命令:sudo -H -u git gitosis -init < /tmp/id_rsa.pub
Initialized empty Git repository in /home/repo/gitosis-admin.git/
Reinitialized existing Git repository in /home/repo/gitosis-admin.git/
说明实例化空的git仓库/home/git/repositories/gitosis-admin.git/已成功了。
获取root权限
light-server@lightserver-GREATWALL-PC:/home$ sudo -i
目录切换:
root@lightserver-GREATWALL-PC:/home/git# cd repositories/
root@lightserver-GREATWALL-PC:/home/git/repositories# ls
gitosis-admin.git
root@lightserver-GREATWALL-PC:/home/git/repositories# cd gitosis-admin.git
root@lightserver-GREATWALL-PC:/home/git/repositories/gitosis-admin.git# ls
config gitosis.conf gitosis-export HEAD hooks index objects refs
更改权限(关键步骤)
root@lightserver-GREATWALL-PC:/home/git/repositories/gitosis-admin.git# sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
root@lightserver-GREATWALL-PC:/home/git/repositories/gitosis-admin.git# exit
准备工作到此结束了,下面可以进行测试了!
15.在服务器上新建一个测试项目仓库
我建了一个叫“teamwork”的仓库。切换到gitadmin用户:
gitadmin@lightserver-GREATWALL-PC:~mkdirteamwork.gitgitadmin@lightserver−GREATWALL−PC: cd teamwork.git/
gitadmin@lightserver-GREATWALL-PC:~/teamwork.git$