git 사내 협업도구 구성.

ITWeb/서버관리 2012. 4. 23. 19:16

보안 이슈로 인해 사내 소스코드를 github 에 public 하게 못 올리다보니.. private 구성을 해봤습니다.
다들 잘 아시는 내용이라.. 저는 그냥 제가 공부하는 차원에서 remind 합니다.


모두 우분투 환경입니다. ^^*


[필요서버]

master 로 사용할 서버 한 대. (192.168.1.1)

local 개발서버 한 대. (192.168.1.2)

[git install]
이전 글 : http://jjeong.tistory.com/650

sudo apt-get install git git-gui git-doc

[git repository]

mkdir git-test (or test.git, 저장소 생성 할때 나름 만들어진 name rule 같내요)

cd git-test

git init

(or git init --bare, 이건 아래 나오겠지만 git push 했을 때 deny 오류가 나지 않도록 하기 위함 입니다. 저는 실제 이렇게 하지는 않았구요, .git/config 를 수정했습니다.)

vi helloworld.txt // 아무 텍스트나 작성해 보시고 저장 후 나오세요.

git add helloworld.txt

git commit -m "init helloworld.txt"

[git clone]
ssh 를 이용해서 clone 작업했습니다.
svn 의 checkout 과 같다고 보시면 됩니다.

[local 개발서버]

git clone jjeong@192.168.1.1:/home/jjeong/git-test

vi helloworld.txt // checkout 텍스트를 삽입 하고 나오세요.

git commit -m "clone text add checkout"

git push

[error detection]

remote: error: refusing to update checked out branch: refs/heads/master

remote: error: By default, updating the current branch in a non-bare repository

remote: error: is denied, because it will make the index and work tree inconsistent

remote: error: with what you pushed, and will require 'git reset --hard' to match

remote: error: the work tree to HEAD.

remote: error: 

remote: error: You can set 'receive.denyCurrentBranch' configuration variable to

remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into

remote: error: its current branch; however, this is not recommended unless you

remote: error: arranged to update its work tree to match what you pushed in some

remote: error: other way.

remote: error: 

remote: error: To squelch this message and still keep the default behaviour, set

remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

이런 에러 발생 시 아래 master 서버에 코드 추가

[master 서버]

vi git-test/.git/config
아래 코드 추가 합니다.

[receive]

    denyCurrentBranch = false


[local 개발서버]

git push 

[git master 반영]
이 부분에서 제가 local 에서 push 한 후 master 쪽 파일 업데이트가 잘 되었는지 확인하는 command 를 몰라서
걍 강제로 적용했구요..ㅡ.ㅡ;;
git log 확인 후 git resert --hard 마지막COMMIT.HASHCODE
다른 방법으로는.. 걍 clone 을 한번 더 떠봤습니다.

git clone jjeong@192.168.1.1:/home/jjeong/git-test git-clone
이렇게 하신 후 git-clone 에 들어 가서 바로 직전에 commit 하고 push 한게 잘 반영 되었는지 확인 하면 되겠습니다.

[master 업데이트 된거 반영]

[local 개발서버]

git pull // 하시면 master 꺼로 업데이트 합니다. (pull 은.. merge 가 아닙니다. 그냥 덮어씁니다.)

[branch & merge]
전 그냥 local 개발서버에서 branch 생성하고 걍.. 거기서 merge 까지 테스트 했습니다.

[local 개발서버]

git branch git-branch

git checkout git-branch

vi helloworld.txt // 그냥 수정해 보세요.

git add helloworld.txt

git commit helloworld.txt -m "오타 내기"

git checkout origin/master

git merge git-branch

기타 git 매뉴얼은 git 사이트에서 참고 하시면 됩니다.

: