개발
[GIT] 서브모듈 본문
서브모듈 추가
- Submodule로 사용할 저장소 추가
git submodule add https://github.com/sub_sub.git
git commit -am 'added submodule'
git push origin master
- main repository clone할 때 서브모듈 디렉토리는 비어있음. 서브모듈 초기화 필요.
git submodule init
git submodule update
- 초기화 필요없이 clone 가능.
git clone --recurse-submodules https://github.com/SubModuleTest.git
서브모듈 업데이트
- 서브모듈 디렉토리에서 실행
git fetch
git merge origin/master
- merge 이후에 서브모듈을 푸쉬해야 main repository에 반영됨.
테스트
- 꼭 루트에서만 서브모듈 등록이 가능할까?
- 루트가아닌 src/js 폴더 밑에서 submodule 추가시 루트의 .gitmodules 파일에서 mapping정보 관리
[submodule "sub_sub"] path = sub_sub url = https://github.com/sub_sub.git [submodule "src/js/sub_sub"] path = src/js/sub_sub url = https://github.com/sub_sub.git
- 서브모듈로 추가한 폴더에서 수정후 서브모듈 repository에 push할 수 있을까?
- DetachedHeader
- https://gitolite.com/detached-head.html
- → push불가
'GIT' 카테고리의 다른 글
[Git] gitIgnore 안될때 (Intellij) (0) | 2022.05.30 |
---|---|
[Git] Pull, merge (Intellij) (0) | 2022.05.26 |
[Git] Fetch,Merge (Intellij) (0) | 2022.05.21 |
[Git] Push,Merge (Intellij) (0) | 2022.05.21 |
Comments