웹마짱구의 블로그

2020/03/24 +1

git 서버 만들기

Git2020. 3. 24. 18:21

참고1:https://git-scm.com/book/ko/v2/Git-%EC%84%9C%EB%B2%84-%EC%84%9C%EB%B2%84-%EC%84%A4%EC%A0%95%ED%95%98%EA%B8%B0

참고2: https://www.youtube.com/watch?v=sAeXpcGCQfI

 

[서버]

$ mkdir git_test

$ cd git_test

$ git init --bare remote

$ cd remote

 

[클라이언트]

$ git init local

$ cd local

$ vi f1.txt

$ git add f1.txt

$ git commit -m 1

$ git remote add origin jjangu@192.168.1.20:/home/jjangu/git_test/remote/

$ git remote -v

origin  jjangu@192.168.1.20:/home/jjangu/git_test/remote/ (fetch)
origin  jjangu@192.168.1.20:/home/jjangu/git_test/remote/ (push)

 

[hooks/post-receive]

#!/bin/bash
TARGET="/home/web/deploy"
GIT_DIR="/home/web/remote"
BRANCH="master"

while read oldrev newrev ref
do
# only checking out the master (or whatever branch you would like to deploy)
if [ "$ref" = "refs/heads/$BRANCH" ];
then
echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH
else
echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
fi
done

Comment +0