1、Git 仓库
$ sudo apt-get install git-core
$ sudo mkdir -p /srv/my.git
$ cd /srv/my.git
$ sudo chown $(whoami) .
$ git --bare init
$ sudo chown www-data:www-data .
2、Apache 设置
$ sudo apt-get install apache2
$ sudo htpasswd -cb /etc/apache2/my.git.passwd [myusername] [mypassword]
$ sudo ln -s ../mods-available/dav_fs.conf ../mods-available/dav_fs.load ../mods-available/dav.load /etc/apache2/mods-enabled/
$ sudo 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
$ sudo service apache2 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