Git Submodule
레포지토리 하위에 다른 저장소를 관리하기 위한 도구
용어
- 슈퍼 프로젝트 : 상위 레포지토리
- 서브 모듈 : 하위 레포지토리
명령어
-
super-repository
의 “dirA” 라는 디렉토리에sub-repository
를 등록하는 경우1$ git submodule add https://github.com/bong-u/sub-repository.git dirA
-
sub-repository
의 변경상황을 반영해야하는 경우1# 1번째 방법 : sub-repository내에서 pull 해야한다 2$ cd dirA 3$ git pull 4# 2번째 방법 5$ git submodule update --remote
-
서브모듈을 포함한 프로젝트 클론하기
1$ git clone --recurse-submodules http://github.com/bong-u/super-repository.git
-
super-repository
와sub-repository
를 한번에 push 하기1# 서브모듈의 변경사항이 push되지 않았으면 fail 2$ git push --recurse-submodules=check 3# 서브모듈의 변경사항을 알아서 푸시 4$ git push --recurse-submoduels=on-demand
-
sub-repository
상태 확인1$ git submodule status
-
서브모듈 삭제하기
1$ git rm -f [서브모듈 경로]