Pro Git
1. 분산 환경에서의 워크 플로
2. 프로젝트에 기여기
3. 프로젝트에 관리하기
중앙 저장소를 하나 두고 Clone한 개발자 모두 Push 권한을 부여
Pro Git
Pro Git
Github나 GitLab 같은 Hub 사이트를 통해 주로 사용하는 방식이다.
1
2
3
4
Pro Git
수백 명의 개발자가 참여하는 큰 프로젝트를 운영할 때 이 방식을 사용한다.
Pro Git
1. 몇명의 개발자가 참여할 것인가?
2. 워크 플로우는 어떻게 할 것인가?
3. 프로젝트의 권한은 어떻게 할 것인가?
Pro Git
Pro Git
$ git checkout -b topicA
... work ...
$ git commit
... work ...
$ git commit
$ git format-patch -M origin/master
0001-add-limit-to-log-function.patch
0002-changed-log-output-to-30-from-25.patch
Pro Git
Pro Git
// 패치파일 생성
$ git format-patch {commit_id}
// 패치파일 적용하기
$ git apply {file_name.patch}
Pro Git
1. 디자이너의 결과물을 개발자에게 전달
2. 개발자는 변경된 파일을 붙여넣기
3. Commit & Push
4. 서비스 배포
Pro Git
1. 디자인과 개발에 적용된 버전 차이 발생
2. 프로젝트 진행중 수정이 빈번하다면
=> 개발자가 너무 수고스러움
=> 커밋이 지저분해짐
Pro Git
Pro Git
$ cd /service_repo/.../resources
=> 서브모듈을 추가할 루트로 이동
$ git submodule add http://stash.daou.co.kr/svc_design
Cloning into 'svc_design'... remote: Counting objects: 11, done. remote: Compressing objects: 100% (10/10), done. remote: Total 11 (delta 0), reused 11 (delta 0) Unpacking objects: 100% (11/11), done. Checking connectivity... done.
Pro Git
$ git status
On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: .gitmodules new file: .../resources/static
Pro Git
$ cat ./gitmodules [submodule "resources/static"] path = resources/static url = http://stash.daou.co.kr/svc_design
Pro Git
$ git diff --cached .../resources/static
diff --git a/DbConnector b/DbConnector new file mode 160000 index 0000000..c3f01dc --- /dev/null +++ b/DbConnector @@ -0,0 +1 @@ +Subproject commit c3f01dc8862123d317dd46284b05b6892c7b29bc => static 디렉토리는 서브모듈로 취급하기 때문에 추적하지 않는다. 대신 통쨰로 특별한 커밋으로 취급한다.
Pro Git
$ git clone http://stash.daou.co.kr/service_repo
$ cd service_repo
$ git submodule init
=> .gitmodule에 있는 정보를 기반으로 로컬 환경설정 파일 셋팅
$ git submodule update
=> 서브모듈에 저장된 스냅샷으로 리모트의 커밋 정보를 가져오고 checkout
Pro Git
$ cd service_repo // 부모 프로젝트
$ git --pretty=short -1
commit b90da54bc5f7b0ca12eb313e1a57581f35ddce38
$ cd service_repo/resources/static // 자식 프로젝트
$ git --pretty=short -1
commit 0d2bb5b91c235fa77fdd8859d9ecbd270fd576d2
=> 각 레포는 각각 origin을 가지고 있고 서로다른 커밋을 바라보고 있다.
Pro Git
$ cd service_repo/resources/static // 자식 프로젝트
$ git commit --allow-empty -m "Add new commit" // 빈 커밋
commit 0d2bb5b91c235fa77fdd8859d9ecbd270fd576d2
$ git log --pretty=short -1 // 0d2bb5b 에서 af2a90a 로 변경
commit af2a90a19766d5ab5ed7d5f59e88403245f99ab1
Pro Git
$ cd service_repo // 부모 프로젝트
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
...
modified: resources/static (new commits)
Pro Git
$ git diff
diff --git a/submodule_test_child b/submodule_test_child index 0d2bb5b..af2a90a 160000 --- a/submodule_test_child +++ b/submodule_test_child @@ -1 +1 @@ -Subproject commit 0d2bb5b91c235fa77fdd8859d9ecbd270fd576d2 +Subproject commit af2a90a19766d5ab5ed7d5f59e88403245f99ab1
Pro Git
$ git commit -am "Update submodule"
$ cd service_repo/resources/static // 자식 프로젝트
$ git push origin master
$ cd service_repo // 부모 프로젝트
$ git push origin master
Pro Git
$ git commit -am "Update submodule"
$ git push origin master
----------------------------------------------------------------
다른 작업자
$ git pull origin master
$ git submodule update
error: no such remote ref f370c4954db667a9c8815028e5905e13c78c48c9
...
Pro Git
$ git push --recurse-submodules=check
The following submodule paths contain changes that can
not be found on any remote:
resources/static
Please try
git push --recurse-submodules=on-demand
or cd to the path and use
git push
to push them to a remote.
$ git config push.recurseSubmodules check
Pro Git
$ git push --recurse-submodules=on-demend
...
c75e92a..82d2ad3 master -> master // 자식 프로젝트
...
3d6d338..9a377d1 master -> master // 부모 프로젝트
$ git config push.recurseSubmodules on-demand
Pro Git
$ cd service_repo/.../resources/static
$ git pull origin master
=> 서브모듈에 변경이 있다면 최신화 한다.
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
...
modified: .gitmodules
modified: resources/static (new commits)
Pro Git
$ git submodule foreach 'git stash'
$ git submodule foreach 'git checkout -b featureA'
$ git diff; git submodule foreach 'git diff'