git
下記から引用
http://d.hatena.ne.jp/mustankatti/20120318/1332101129
気まぐれコーディング
<[wordpress][php] wordpressのプ...
2012-03-18
gitでhttp-backendをつかってpush
git, apache
結構はまったので、めも。
ubuntu 10.04
apache2, git, gitwebをapt経由でインストール済み。
目的: http://
プロジェクトの位置は /var/www/repos/test.git
まず、/etc/apache2/conf.d/git.confに設定情報を記述
SetEnv GIT_PROJECT_ROOT /var/www/repos
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /repos/ /usr/lib/git-core/git-http-backend/
<LocationMatch "^/repos/.*">
AuthType Basic
AuthName "Git Access"
Require valid-user
AuthUserFile /etc/apache2/passwd.git
</LocationMatch>
で、/etc/apache2/passwd.gitを作成。
htpasswd -c /etc/apache2/passwd.git
ついでに、gitwebも/etc/apache2/gitwebに設定。
こっちは http://
Alias /gitweb /usr/share/gitweb
<Directory /usr/share/gitweb>
Options FollowSymLinks +ExecCGI
AddHandler cgi-script .cgi
</Directory>
プロジェクトの位置をgitwebに教える
/etc/gitweb.conf
$projectroot = "/var/www/repos"
...
apache2をrestart
/etc/init.d/apache2 restart
以上で設定完了。
gitserverにレポジトリ作成.
cd /var/www/repos
mkdir test.git
cd test.git
git init --bare --shared=true
クライアント側でcloneとpushしてみる。
git clone http://
cd test
touch README
git add .
git commit -m "first"
git remote -v # 確認
git push origin master
できた。
何度もpasswordを聞かれるのがうるさいので、 ~/.netrcにパスワードを記述。
machine <gitserver>
login <htpasswdのuser>
passwd <htpasswdのpassword>
特にはまったところは、gitのapacheの設定で、LocationMatchを "^/repos/.*/git-receive-pack$"としていた際に、git cloneができても、その後のgit pushが次のようなエラーが出て失敗したこと。
error: Cannot access URL http://
fatal: git-http-push failed
git-receive-packだけを対象とせず "^/repos/.*"としたらうまく行った。
参考
http://manpages.ubuntu.com/manpages/lucid/man1/git-http-backend.1.html