アイデアは、あなたが--work-tree=/path/
オプションを使用して、特定の作業ディレクトリにチェックアウトを得ることができ、サーバー上post-receive hook
を使用することで、特定のディレクトリに
を強制 (-f
オプション)チェックアウトを設定します。.. 。this Gistによって適合
サンプルコードは、(実行ビットが設定されたファイルhooks/post-receive
としてサーバーの塗装されていないリポジトリに保存される)とすることができる:
#!/bin/bash
echo '--- --- --- --- --- --- --- --- --- --- ---'
echo 'Deploying site...'
echo '--- --- --- --- --- --- --- --- --- --- ---'
if ! [ -t 0 ]; then
read -a ref
fi
IFS='/' read -ra REF <<< "${ref[2]}"
branch="${REF[2]}"
# Master Branch
if [ "PROD" == "$branch" ]; then
git --work-tree=/path/to/public/PROD checkout -f $branch
echo 'Changes pushed to production site'
fi
# Stage Branch
if [ "STAGE" == "$branch" ]; then
git --work-tree=/path/to/public/STAGE checkout -f $branch
echo 'Changes pushed to stage site'
fi
# Development Branch
if [ "DEV" == "$branch" ]; then
git --work-tree=/path/to/public/DEV checkout -f $branch
echo 'Changes pushed to dev site'
fi
echo '--- --- --- --- --- --- --- --- --- --- ---'
チェックアウトのための別の可能なsintaxは
GIT_WORK_TREE=/path/to/test/site git checkout -f
です。これは非常に標準的な設定です。あなたの質問は何ですか? –
さて、私はその解決策をまだ知りませんでしたが、それが私が求めていた理由です。カルロは私にこの素晴らしい解決策を提供しました! –