リポジトリの新規作成
1. サーバーでbareリポジトリを作成
bareリポジトリを作成
# mkdir -p /opt/repo/src.git
# cd /opt/repo/src.git
# git init --bare
2. サーバーでbareリポジトリをclone
リポジトリのクローンを作成
# cd /opt
# git clone /opt/repo/src.git
3. ローカルでサーバーのbareリポジトリをclone
リポジトリのclone
# git clone ssh://192.168.11.11/opt/repo/src.git
4. ローカルでなにかコミットする
何かファイルを作ってコミットしておく。
# cd src
# date > memo.txt
# git add memo.txt && git commit -m "memo"
5. ローカルでサーバーにpush
リモートリポジトリにpush
# git push --all
自動更新用にHookスクリプトを作成
1. サーバーで作業
# cd /opt/repo/src.git/hooks/
# cp -a post-receive.sample post-receive
2. サーバーでpost-receiveを編集
post-receive
+ cd /opt/src
+ git --git-dir=.git pull
3. ローカルからサーバーにコミットをpushする
何かファイルを作ってコミットしておく。
# echo "hoge" > memo.txt
# git add memo.txt && git commit -m "hoge"
リモートリポジトリにpush
# git push
4. 変更を確認する
これで、/opt/src/memo.srcの内容が自動で更新される。