2

現時点では、リモート リポジトリが更新されるたびに (つまり、だれかが git push を実行するたびに) スクリプトを実行して、リポジトリ内のファイルからパッケージをビルドする必要があるというジレンマに陥っています。これらのパッケージは、後で使用するために HTTP 経由でクライアントに公開される git サーバー上のディレクトリに配置されます。

問題は、更新後のフックでリポジトリ内のファイルにアクセスする方法がわからないことです。

誰かが洞察を与えることができれば、それは大歓迎です。

4

2 に答える 2

3

まず、post-update の代わりに post-receive フックを使用することをお勧めします。githooks(5)の man ページによると、post-receive が post-update に取って代わります。

つまり、フック スクリプトは .git/hooks サブディレクトリで実行されるため、単純な

cd ..

スクリプトは git リポジトリの作業ツリーにあります。たとえば、リポジトリにプッシュするたびにリモート git リポジトリの作業ツリーが更新されるようにする小さなスクリプトを次に示します。

#!/bin/sh
export GIT_DIR=
cd ..
echo "Resetting working tree..."
git reset --hard
echo "Finished resetting working tree."

GIT_DIR 環境変数の設定を解除する必要があることに注意してください。自動的に設定され、設定されている限り、すべての git コマンドがそのディレクトリで実行されます - どこに cd したかに関係なく。

于 2009-10-13T10:37:30.310 に答える
1

リモートリポジトリが裸の共有リポジトリである場合、ファイルのコピーはありません。これは変更できます。後は、自動チェックアウトを実行するだけです。

hte ファイルをパッケージ化する場合は、レポも別のディレクトリに置くのが最善です

私はあなたが命名した正確な目的のために以下を使用します

これは、セットアップ方法を示したブログ投稿です http://toroid.org/ams/git-website-howto

here are my abbrieviated notes below

make a directory outside the repo and put the working tree there, then make it no longer a bare repo so there is a copy of the files, then run a before you run your packaging script

            # create the repo with files that live in a seperate folder
            cd /share/proj/all/$1/repo
            git --bare init --shared
            git config core.worktree ../actual
            git config core.bare false
            git config receive.denycurrentbranch ignore
            # add a hook to checkout the repo into the files directory automatically on push
            echo "#!/bin/sh" > hooks/post-receive
            echo "git checkout -f" >> hooks/post-receive
            chmod +x hooks/post-receive
于 2009-10-14T20:38:57.117 に答える