#http://www.wretch.cc/blog/michaeloil/22286355#http://blog.longwin.com.tw/2009/05/build-git-env-over-http-2009/#安裝軟體sudo apt-get install git-coresudo apt-get install apache2#啟用相應模組a2enmod dav_fsa2enmod dav#設定apache2sudo htpasswd -c /etc/apache2/dav_git.passwd dav>New password: 123>Re-type new password: 123>Adding password for user davsudo vim /etc/apache2/sites-available/git.conf<VirtualHost *:80> ServerAdmin user@example.com DocumentRoot /var/cache/git ServerName git.example.com ErrorLog /var/log/apache2/git-error.log CustomLog /var/log/apache2/git-access.log combined
SetEnv GIT_PROJECT_ROOT /var/cache/git/
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias / /usr/lib/git-core/git-http-backend/
<Location "/test.git"> DAV on AuthType Basic AuthName "Git" AuthUserFile /etc/apache2/dav_git.passwd # password filename Require valid-user </Location></VirtualHost>#刪除原來監聽80連接埠的預設檔案sudo rm /etc/apache2/sites-enabled/000-default#啟用新的git配置sudo ln -s /etc/apache2/sites-available/git.conf /etc/apache2/sites-enabled/git.conf#重啟sudo /etc/init.d/apache2 restart#設定gitsudo mkdir -p /var/cache/git/project_name.gitcd /var/cache/git/project_name.gitsudo git --bare initsudo git update-server-infosudo cp hooks/post-update.sample hooks/post-updatesudo chown www-data:www-data -R .goodspeed@bogon:/var/cache/git$ sudo rm -r project_name.gitgoodspeed@bogon:/var/cache/git$ cd project_name.git-bash: cd: project_name.git: No such file or directorygoodspeed@bogon:/var/cache/git$ mkdir project_name.gitmkdir: cannot create directory `project_name.git': Permission deniedgoodspeed@bogon:/var/cache/git$ sudo mkdir project_name.gitgoodspeed@bogon:/var/cache/git$ cd project_name.git/goodspeed@bogon:/var/cache/git/project_name.git$ sudo git --bare initInitialized empty Git repository in /var/cache/git/project_name.git/goodspeed@bogon:/var/cache/git/project_name.git$ sudo chown www-data:www-data -R .goodspeed@bogon:/var/cache/git/project_name.git$ sudo git update-server-infogoodspeed@bogon:/var/cache/git/project_name.git$ sudo cp hooks/post-update.sample hooks/post-updategoodspeed@bogon:/var/cache/git/project_name.git$ sudo chown www-data:www-data -R .goodspeed@bogon:/var/cache/git/project_name.git$ llcurl --netrc --location http://127.0.0.1/test.git/HEADcurl --netrc --location -v http://127.0.0.1/test.git/HEAD