質問
ようにしている設定にGitのための演出デザイン画のシートできたらいいのに git pull
の現在のバージョンで作業での地元のとし git push
プへの変更リモートサーバーです。そうだったんで設定が動作するようにしたいのですが、後押しして手動で実行 git checkout -f
または git reset --hard HEAD
すべてのポートシャーロットのサーバーです。
ってそれをシェルスクリプトとしてのポストを受けフックのサーバーが、それだけではなさそう影響はありません。のを知っているスクリプトが実行で見かけの変更"を押しサーバー"の後にした。こちらは、ポストを受けフック:
#!/bin/sh
git reset --hard HEAD
echo "Changes pushed to server."
解決
その答えはご質問はこちら: http://toroid.org/ams/git-website-howto
にしたいことは追加"一戸建ての仕事のツリーの裸のリポジトリ通常のお仕事をツリーを含む .git
ディレクトリです。裸のリポジトリがない事によってツリーに定義が作成できますし、この異なるディレクトリ以外の素呼ぶ。
のポストを受けフックするだけのシンプルな git checkout -f
タのリポジトリの HEAD
の作業ディレクトリです。このディレクティブはApacheがそのドキュメントルート、のみです。時にプッシュして、裸のリポジトリでは、Apacheは直ちに受けます。
私は一般的に使用する自動でプッシュに演出でサーバへの参照の場合は"本当の"環境puke私の変わります。への展開、ライブサーバは全く異なる。:-)
他のヒント
2015年3月の更新
私が述べたように」リモートリポジトリに変更をプッシュするとき、このgit警告メッセージは何ですか?「、あなたは実際にプッシュすることができます 直接 今すぐ非ベアリポジトリ(GIT 2.3.0+、2015年2月)へ:
git config receive.denyCurrentBranch updateInstead
それに応じて作業ツリーを更新しますが、コミットされていない変更がある場合はそうすることを拒否します。
これにより、レシーブ後のフックを回避できます。
(元の回答:2010年10月)
gitfaq 推奨 非ベアリポジトリ このポストアップデートフック:
(フックの実行で実際に何が起こっているのかについての詳細な手がかりを与えるかもしれません。これは、ポストレシーブではなく、アップデート後のフックです)
#!/bin/sh
#
# This hook does two things:
#
# 1. update the "info" files that allow the list of references to be
# queries over dumb transports such as http
#
# 2. if this repository looks like it is a non-bare repository, and
# the checked-out branch is pushed to, then update the working copy.
# This makes "push" function somewhat similarly to darcs and bzr.
#
# To enable this hook, make this file executable by "chmod +x post-update".
git-update-server-info
is_bare=$(git-config --get --bool core.bare)
if [ -z "$is_bare" ]
then
# for compatibility's sake, guess
git_dir_full=$(cd $GIT_DIR; pwd)
case $git_dir_full in */.git) is_bare=false;; *) is_bare=true;; esac
fi
update_wc() {
ref=$1
echo "Push to checked out branch $ref" >&2
if [ ! -f $GIT_DIR/logs/HEAD ]
then
echo "E:push to non-bare repository requires a HEAD reflog" >&2
exit 1
fi
if (cd $GIT_WORK_TREE; git-diff-files -q --exit-code >/dev/null)
then
wc_dirty=0
else
echo "W:unstaged changes found in working copy" >&2
wc_dirty=1
desc="working copy"
fi
if git diff-index --cached HEAD@{1} >/dev/null
then
index_dirty=0
else
echo "W:uncommitted, staged changes found" >&2
index_dirty=1
if [ -n "$desc" ]
then
desc="$desc and index"
else
desc="index"
fi
fi
if [ "$wc_dirty" -ne 0 -o "$index_dirty" -ne 0 ]
then
new=$(git rev-parse HEAD)
echo "W:stashing dirty $desc - see git-stash(1)" >&2
( trap 'echo trapped $$; git symbolic-ref HEAD "'"$ref"'"' 2 3 13 15 ERR EXIT
git-update-ref --no-deref HEAD HEAD@{1}
cd $GIT_WORK_TREE
git stash save "dirty $desc before update to $new";
git-symbolic-ref HEAD "$ref"
)
fi
# eye candy - show the WC updates :)
echo "Updating working copy" >&2
(cd $GIT_WORK_TREE
git-diff-index -R --name-status HEAD >&2
git-reset --hard HEAD)
}
if [ "$is_bare" = "false" ]
then
active_branch=`git-symbolic-ref HEAD`
export GIT_DIR=$(cd $GIT_DIR; pwd)
GIT_WORK_TREE=${GIT_WORK_TREE-..}
for ref
do
if [ "$ref" = "$active_branch" ]
then
update_wc $ref
fi
done
fi
これが機能するには、これらの構成設定のいずれかを使用して、現在のブランチへの変更を具体的にプッシュすることを許可する必要があります。
git config receive.denyCurrentBranch ignore
また
git config receive.denyCurrentBranch warn
まったく同じ問題がありました。このリンクへの返信で: http://toroid.org/ams/git-website-howto - 次のコマンドがそれを実行しました:
sudo chmod +x hooks/post-receive
私たちは逃しました sudo
許可は最初にものを構成しました。
VONCのスクリプトの固定バージョンは、私のために機能します(まったく保証なし)。
#!/bin/sh
#
# This hook does two things:
#
# 1. update the "info" files that allow the list of references to be
# queries over dumb transports such as http
#
# 2. if this repository looks like it is a non-bare repository, and
# the checked-out branch is pushed to, then update the working copy.
# This makes "push" function somewhat similarly to darcs and bzr.
#
# To enable this hook, make this file executable by "chmod +x post-update".
set -e
git update-server-info
is_bare=$(git config --get --bool core.bare)
if [ -z "${is_bare}" ]
then
# for compatibility's sake, guess
git_dir_full=$(cd $GIT_DIR; pwd)
case $git_dir_full in */.git) is_bare=false;; *) is_bare=true;; esac
fi
update_wc() {
ref=$1
echo "Push to checked out branch $ref" >&2
if [ ! -f ${GIT_DIR}/logs/HEAD ]
then
echo "E:push to non-bare repository requires a HEAD reflog" >&2
exit 1
fi
if (cd ${GIT_WORK_TREE}; git diff-files -q --exit-code >/dev/null)
then
wc_dirty=0
else
echo "W:unstaged changes found in working copy" >&2
wc_dirty=1
desc="working copy"
fi
if git diff-index --cached HEAD@{1} >/dev/null
then
index_dirty=0
else
echo "W:uncommitted, staged changes found" >&2
index_dirty=1
if [ -n "$desc" ]
then
desc="$desc and index"
else
desc="index"
fi
fi
if [ "$wc_dirty" -ne 0 -o "$index_dirty" -ne 0 ]
then
new=$(git rev-parse HEAD)
echo "W:stashing dirty $desc - see git-stash(1)" >&2
( trap 'echo trapped $$; git symbolic-ref HEAD "'"$ref"'"' 2 3 13 15 ERR EXIT
git update-ref --no-deref HEAD HEAD@{1}
cd ${GIT_WORK_TREE}
git stash save "dirty $desc before update to $new";
git symbolic-ref HEAD "$ref"
)
fi
# eye candy - show the WC updates :)
echo "Updating working copy" >&2
(cd ${GIT_WORK_TREE}
git diff-index -R --name-status HEAD >&2
git reset --hard HEAD
# need to touch some files or restart the application? do that here:
# touch *.wsgi
)
}
if [ x"${is_bare}" = x"false" ]
then
active_branch=$(git symbolic-ref HEAD)
export GIT_DIR=$(cd ${GIT_DIR}; pwd)
GIT_WORK_TREE="${GIT_DIR}/.."
for ref in $(cat)
do
if [ x"$ref" = x"${active_branch}" ]
then
update_wc $ref
fi
done
fi
このgit展開を設定するための簡単なスクリプト:
レシーブ後のフックの準備:
echo '#!/bin/sh' > .git/hooks/post-receive
echo 'git checkout -f' >> .git/hooks/post-receive
echo 'git reset --hard' >> .git/hooks/post-receive
chmod +x .git/hooks/post-receive
裸ではありませんが、このリポジトリへのプッシュを許可します。
git config receive.denycurrentbranch false
私はただ推測しているだけですが、これは許可の問題かもしれません(フルパスが必要ですか? cd
?)。ログファイルで実際に起こっていることを確認してください。
ただし、GITを介してファイルを公開することは、常に公開プロセスの1つのタスクにすぎません。通常、いくつかのファイルをコピーし、その他のセットアップを削除し、アクセス許可を更新し、ドキュメントを生成する必要があります。
複雑なソリューションの場合、ビルドスクリプトはどのgitフックよりも優れている場合があります。これらのタスクを非常にうまく処理できるツール:
(これはあなたが期待している答えではないことに気づきましたが、コメントとして投稿するには長すぎます)