LoginSignup
4
4

More than 3 years have passed since last update.

git pullを自動で行う

Last updated at Posted at 2019-10-30

サーバーに構築したgitレポジトリからcloneしたディレクトリをいちいちgit pullしてられませんということで試してみたら意外とすぐできたのでメモ

/home/git/test

/home/git/test/test.gitがある状態で、
/home/git/test/以下にソースがある状態と仮定

$ cd /home/git/test/test.git
$ cd hooks
$ ls
applypatch-msg.sample      post-update.sample         pre-push.sample            prepare-commit-msg.sample
commit-msg.sample          pre-applypatch.sample      pre-rebase.sample          update.sample
fsmonitor-watchman.sample  pre-commit.sample          pre-receive.sample

適当に上記ファイルのどれかを複製してpost-receiveを作成する
そのファイルの内容を編集する

cd /home/git/test/
git --git-dir=.git pull origin master

と記述するだけ。
1行目 = ソースがあるディレクトリ(cloneしたディレクトリ)
2行目 = 1行目で指定したディレクトリに対してpullさせる

これでローカルからpushしたら自動的にpullがされるようになりました。ちゃんちゃん

4
4
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
4
4