サブモジュールを含む post-receive フックでサーバー上の裸のリポジトリをチェックアウトするにはどうすればよいですか?
私は現在これを受信後フックとして持っています:
#!/bin/bash
# http://blog.ekynoxe.com/2011/10/22/git-post-receive-for-multiple-remote-branches-and-work-trees/
# post-receive hook that checks out development branch after a push to the bare
# repo
# paths must exist
livepath="/var/www/live"
devpath="/var/www/dev"
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
#if [[ "master" == "$branch" ]]; then
# git --work-tree=$livepath checkout -f $branch
# echo 'Changes pushed live.'
#fi
if [[ "develop" == "$branch" ]]; then
git --work-tree=$devpath checkout -f $branch
echo 'Changes pushed to dev.'
fi
done
しかし、これではサブモジュールは初期化されません。
マニュアルのテストのためにこれを試しました:
cd /var/www/dev
git --work-tree /var/www/dev --git/dir /git/myrepo.git submodule init
git --work-tree /var/www/dev --git/dir /git/myrepo.git submodule update
submodule update
コマンドは次のエラー メッセージで失敗しました:
fatal: working tree '/var/www/dev' already exists.
Clone of 'https://github.com/yiisoft/yii.git' into submodule path 'yii' failed
その動作はすでに (未回答) ここで疑問視されています: Git submodules with separate work_tree
それらがすでにそこにある場合、それらを再初期化しないのも良いでしょう。