개발

[GIT] 서브모듈 본문

GIT

[GIT] 서브모듈

Dev.hs 2021. 11. 17. 17:02

서브모듈 추가

  • 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

'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