gitをデプロイメントツールとして使用しようとしているので、プロダクションブランチへのプッシュがあったときに、それに応じてリモートサーバを更新したいと思います。しかし、私が2番目のコマンド(プル)を実行すると、エラーが返ってきますOperation must be run in a work tree.
誰かが正しい方向に私を向けることができますか?gitをデプロイメントツールとして使用する
ここにはbashスクリプトの一部のサンプルがあります。
echo -e "Thank you for pushing your changes to ${project}. \nHold on while I update the required directories..."
GIT_WORK_TREE=/home/www/${project} git checkout -f
echo "Local directory updated!"
for ref in [email protected]; do
echo $ref
if [ "$ref" = "refs/heads/production" ]; then
# Before we could set the GIT directory strictly from the local environment
# but the case might not be the same remotely. Need absolute paths.
ssh [email protected] GIT_DIR=/home/www/${project}/.git GIT_WORK_TREE=/home/www/${project} git checkout -f production
ssh [email protected] GIT_DIR=/home/www/${project}/.git GIT_WORK_TREE=/home/www/${project} git pull -f production
echo "Production push completed"
fi
done
EDIT:あなたは、 "展開" を検討レポは裸のリポジトリであるようですね
remote: fatal: /usr/lib/git-core/git-pull cannot be used without a working tree.
独自の展開スクリプトを使用する代わりに、[Capistrano](https://github.com/capistrano/capistrano)を調べる必要があります。 – meagar
Gitはデプロイメントツールではありませんが、十分なスクリプティングであれば、ちょっとしたことができます。 http://toroid.org/ams/git-website-howtoを参照してください。しかし、はい、maegarは正しいです。それは非裸である必要があります(通常、プライマリアップストリームサーバーのコピーではなく、具体的にはプッシュするレポです) 。 –