1、Git 仓库
$ mkdir -p /srv/my.git
$ cd /srv/my.git
$ git --bare init
2、Apache 设置
$ htpasswd2 -cb /etc/apache2/my.git.passwd [myusername] [mypassword]
$ ln -s ../extra/httpd-dav.conf /etc/apache2/conf.d/
$ sh <<__EOF
cat > /etc/apache2/conf.d/my.git.conf <<_EOF
Alias /my.git /srv/my.git
<Directory /srv/my.git>
Order Allow,Deny
Allow from all
DAV on
AuthType Basic
AuthName Git
AuthUserFile /etc/apache2/my.git.passwd
Require valid-user
</Directory>
_EOF
__EOF
$ /usr/sbin/apachectl2 restart
3、客户端设置
$ cat >> ~/.netrc <<_EOF
machine [server]
login [myusername]
password [mypassword]
_EOF
4、客户端测试
$ mkdir my
$ cd my
$ git init
$ echo "Test" >> README
$ git add README
$ git commit -m "add README"
$ git push http://[server]/my.git master