ローカルでpushしたら自動的にVPS上の公開用ディレクトリでpullする
Git初心者の自分用メモ。
bareリポジトリをVPSに作って、 ローカルでpushしたら自動的にVPS上の公開用ディレクトリでpullする。 (bareリポジトリはワーキングディレクトリをもたない)
bareリポジトリはワーキングディレクトリをもたない。 リポジトリ作る。
cd repos
mkdir shintyoku-bot.git
cd shintyoku-bot.git
git init --bare
サンプルを元にpost-receive書く。
cp hooks/post-receive.sample hooks/post-receive
echo "(cd /home/teshi/public/shintyoku-bot; git --git-dir=.git pull)" >> hooks/post-receive
公開用ディレクトリにクローン。
cd ~/public
git clone ../repos/shintyoku-bot.git
ローカルでgit remote add
git remote add origin ssh://name@hoge.jp/home/name/repos/shintyoku-bot.git
めっちゃ便利だ。