서브모듈 추가
git submodule add [주소] [경로]
ex) git submodule add test@test.cf:/Users/test/git_repository/test_lib.git External/test_lib
처음 추가시 .gitmodules와 주소의 마지막 디렉토리 이름으로 폴더가 생성된다
git status 입력시 .gotmodules와 test_lib디렉토리가 추가되어있다
commit 과 push로 저장소에 저장
서브 모듈이 포함된 프로젝트 clone
해당 프로젝트를 그냥 clone한 경우 서브모듈 디렉토리(test_lib)은 비어 있다
git submodule init
git submodule update
두 명령을 추가로 입력해야 서브모듈파일도 추가된다
다음 옵션을 붙여 clone하는 경우 자동으로 init와 update를 해준다
clone --recurse-submodules
모든 서브모듈 한번에 업데이트
git submodule update --init --recursive
서브 모듈 삭제
- .gitmodules 에서 서브모듈 제거
- .git/config 에서 서브모듈 제거
- .git/modules에 들어가서 해당 서브모듈 폴더를 제거
- 서브 모듈 폴더 제거
서브 모듈 리스트 확인
.gitmodules가 있는 폴더로 이동해서 다음을 입력
git submodule
출력 정보
[서브모듈이 현재 체크아웃한 커밋] [서브모듈 경로] [브랜치 정보]
pull 할때 서브모듈도 한번에 업데이트
git pull --recurse-submodules
설정 수정
git config submodule.recurse true
GitFork
1. 좌측 메뉴에서 Submodules -> 우클릭 -> Add New SubModule... 선택
2. 대상 저장소와 폴더를 설정하고 Add Submodule 선택
3. 추가됨
4. Sated된 정보를 commit & push