????????????????????汾????????????????????????????????????????????й??GitHub?????????????????????????????????????????????????????????Git??????????????Gitosis?????????????????????
????????????
?????????? CentOS6.6 + git??version 1.8.3.1??
????????? Windows10 + git??version 2.11.1.windows.1??
????1. ???Git??????
????Linux?????????????Windows????????????????Git
?????????????
????[root@Linuxprobe ~]# yum install -y git
????[root@localhost ~]# git --version     //???????? Git ?汾
????git version 1.8.3.1
?????????????
???????? Git for Windows ??????? https://git-for-windows.github.io/
???????????????????Git Bash????????п?????
????$ git --version
????git version 2.11.1.windows.1       //??????????Git?汾
???????Gitosis
????[root@linuxprobe ~]# cd software/
????[root@linuxprobe software]# git clone https://github.com/res0nat0r/gitosis.git
????[root@linuxprobe software]# yum install python-setuptools -y
????[root@linuxprobe software]# cd gitosis
????[root@linuxprobe gitosis]# sudo python setup.py install
???????????????????????????
????Using /usr/lib/python2.6/site-packages
????Finished processing dependencies for gitosis==0.2
????2. ???????????git?????????Git????
????[root@linuxprobe ~]# id git      //??git?????????
????id: git: no such user
????[root@linuxprobe ~]# useradd git
????[root@linuxprobe ~]# echo "123" | passwd --stdin git
????[root@linuxprobe ~]# su - git   //?л???git?????
????3. ???ù??
??????Windows?????ù??????git??????????Щ?????????????????????????????????????????git????????????????git??????
????$ ssh-keygen -t rsa     //????????????????????
????~ scp ~/.ssh/id_rsa.pub git@192.168.34.184:~    //?????git????????
????4. ????gitosis
???????git??????????gitosis
????[root@linuxprobe ~]# cd .ssh
????[root@linuxprobe ~]# gitosis-init < ./id_rsa.pub
????Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/
????Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/
????[root@linuxprobe ~]# chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update     //??????
??????Windows???????clone gitosis-admin????????????
????$ git clone ssh://git@192.168.34.184:22/gitosis-admin.git
????$ cd gitosis-admin
????$ ls
????$ gitosis.confkeydir
????gitosis.conf : git?????????????
????keydir : ?????????
????????gitosis.conf???
????$ vim gitosis.conf
????[gitosis]
????[group gitosis-admin]            #??????
????members = yueyong@SHA2-001       #????
????writable = gitosis-admin         #???????
????[group test]               //?????????"test"????飬???????git??????
????members = yueyong@SHA2-001
????writable = test
??????Windows??????????????????test??????????git?????
????$ git config --global user.name "Your Name"         //?????????????????????????????????????
????$ git config --global user.email "email@example.com"
????$ cd ~/repo
????$ mkdir test
????$ git init
????$ tocuh readme.txt
????????????????
????$ git add .
????$ git commit -a -m 'init test'
????$ git remote add repo git@192.168.186.129:test.git   //repo ?????????????????????????
????$ git push repo master    //??????????з?????????????????
?????????????????test???
????[git@repositories]# pwd
????/home/git/repositories
????[git@linuxprobe repositories]$ ls
????gitosis-admin.git  test.git
????5.???????git?????????
????????????????????????????????????????????/home/git/.ssh/authorized_keys????鷳??????????Windows?????????????????????????????id_rsa.pub??????????????????????úú??????????????????????????????????????????????????????
????$ cd ~/gitosis-admin/keydir
????$ mv ~/id_rsa.pub zhangsan@SHA2-002.pub          //????????????.pub
????$ vim gitosis.conf
????[group test]
????writable = test
????members = yueyong@SHA2-001 zhangsan@SHA2-002    //?????
????$ git add .
????$ git commit -m "add zhangsan@SHA2-002 pub and update gitosis.conf"
????$ git push repo master
?????????????????????????????????????????????????????????????????????????????????clone???????????
????git clone git@192.168.34.184:/home/git/repositories/test.git
????????????ERROR:gitosis serve main repository read access denied
???????????????????????key??????????????飬???????e????/home/git/repositories/test.gitд???
????git clone git@192.168.34.184:test.git
???????????????