3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

サーバーのベアリポジトリにpushされたら、サーバー上にある公開ディレクトリからpullする

Posted at

Wordpressのテーマをgit push で即時反映させて、なおかつBitbucketにバックアップ目的にpushするための環境を構築中

前の作業でVPS上にgit push はできるようになったので、pushされたのをとりあえずWordpressの該当のテンプレートの置き場所にpullする方法を試してました。

全部やってから気づいたんですが、これって ベアリポジトリを作らずにサーバー上の普通のリポジトリにそのままpushすれば良かったのでは?サーバー上を直接編集することもないし。

…そんな事を考えましたがよくわかりません。

やり方

~/git-repos/wordpress-paw.git にベアリポジトリを作って、

wordpress-paw.git/hooks/post-receive
pwd
cd /var/www/blog.poligloto.info/wp-content/themes/paw
pwd
git --git-dir=.git pull ~/git-repos/wordpress-paw.git master

とまあ自分の場合はこんな感じにして、ローカルから git push すればちゃんと git pull も行われて最新状態に反映されました。

後はBitbucktにバックアップさせるだけですね!(すごくめんどくさくなってきてる。)

参考

gitのpost-receiveフックを使ってみる(全部ローカル) - プログラムとかののblog
http://d.hatena.ne.jp/pogin/20130202/1359784619

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?