1
1

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.

ベアリポジトリにプッシュすると勝手にデプロイされる仕組み

Last updated at Posted at 2019-10-07

何番煎じかわからないけれど…

すぐ試せるように手順だけ書きます。

概要

  • bareRepo.git
    • 中央リポジトリ
    • 差分情報だけ、ファイルはない
  • publishedRepo
    • デプロイ先ディレクトリ
    • 直接さわらない
  • localRepo
    • 作業用ディレクトリ
    • ここで作業して中央リポジトリにプッシュする

手順

$ mkdir ~/testdir
$ cd ~/testdir
$ git init --bare --shared bareRepo.git
$ touch bareRepo.git/hooks/post-receive
$ chmod +x bareRepo.git/hooks/post-receive
$ vim bareRepo.git/hooks/post-receive

以下の内容を記述します。

bareRepo.git/hooks/post-receive
#!/usr/bin/env bash

cd ~/testdir/publishedRepo
git --git-dir=.git pull
$ git clone bareRepo.git publishedRepo
$ git clone bareRepo.git localRepo
$ cd localRepo
$ echo Hello, world! > README.md
$ git add README.md
$ git commit -m "Initial commit"
$ git push origin master
$ cd ../publishedRepo
$ cat README.md

publishedRepoでは直接作業していませんが、Hello, world!と表示されます。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?