git submodule 사용법 (서브모듈 속 서브모듈도)

git submodule status 
=> 현재의 서브모듈 목록 출력, 서브모듈 안에서 실행하면 서브모듈 속의 서브모듈 목록이 나온다.
=>
$ git submodule status 
 63a581aa479aa46f76f3efd0b435f4264d259476 third_party/js-color (v1.0.20241230)
 64123a3f1af9016dd4a461c74f17aa221d012ee5 third_party/ui-input-stepper (64123a3)
-87eb4a312722e20fee14094a19106762a7095a00 third_party/ui_ColorPalette     <--- 서브모듈은 추가 되었지만, 가져오지 않은 상태





git submodule add {GIT 주소} [추가될 경로]
=> 서브모듈은 추가하는 방법
==> 추가될 경로를 지정하면 그 경로에 추가, 없으면 현재 폴더에 자동으로 git이름 폴더 생성 후 추가
=> .gitmodules 파일 내용 확인하면 추가되어있을것이다.
[submodule "third_party/ui_ColorPalette"]
path = third_party/ui_ColorPalette
url = https://github.com/mins01/ui_ColorPalette.git
=> 이미 추가되어있어서 이부분은 스킵
=> git submodule add https://github.com/mins01/ui_ColorPalette.git  처럼 사용

git submodule init {서브모듈 지정 경로}
=> 해당 서브모듈을 사용할 수 있게 초기화 
=>
$ git submodule init third_party/ui_ColorPalette
Submodule 'third_party/ui_ColorPalette' (https://github.com/mins01/ui_ColorPalette.git) registered for path 'third_party/ui_ColorPalette'

git submodule update {서브모듈 지정 경로}
=> 서브모듈의 내용을 가져온다.
=> 이때 주의점은 서브모듈 속에 서브모듈이 있다면 안가져온다. 다시 init와 update 해줘야한다. 
=>
$ git submodule update third_party/ui_ColorPalette
Cloning into '~~~~~/third_party/ui_ColorPalette'...
Submodule path 'third_party/ui_ColorPalette': checked out '87eb4a312722e20fee14094a19106762a7095a00'


git submodule status --recursive
=> 서브모듈 속 서브모듈까지 나오도록 --recursive 옵션 사용
=> 명령어 실행 한 경로에 따라서 차이가 있을 수 있다. 아래 명령은 git root 에서 실행
$ git submodule status --recursive
 63a581aa479aa46f76f3efd0b435f4264d259476 third_party/js-color (v1.0.20241230)
 64123a3f1af9016dd4a461c74f17aa221d012ee5 third_party/ui-input-stepper (64123a3)
 87eb4a312722e20fee14094a19106762a7095a00 third_party/ui_ColorPalette (heads/master)
-47218224921ee517aadd062a404bb8bbf8b96db6 third_party/ui_ColorPalette/InputRangeBox
-ae6d69c41fd85308d9117e534a7e26ceb0233d12 third_party/ui_ColorPalette/toDraggable


$ cd third_party/ui_ColorPalette/   <-- 경로 이동후
$ git submodule status    <-- 서브모듈 확인
-47218224921ee517aadd062a404bb8bbf8b96db6 InputRangeBox
-ae6d69c41fd85308d9117e534a7e26ceb0233d12 toDraggable
=> 서버모듈의 서브모듈은 그 서브모듈 폴더 속의 .gitmodules 에서 따로 관리된다.
=>
[submodule "toDraggable"]
path = toDraggable
url = https://github.com/mins01/ui_toDraggable.git
[submodule "InputRangeBox"]
path = InputRangeBox
url = https://github.com/mins01/ui_InputRangeBox.git



$ git submodule init InputRangeBox
Submodule 'InputRangeBox' (https://github.com/mins01/ui_InputRangeBox.git) registered for path 'InputRangeBox'
$ git submodule update InputRangeBox
Cloning into '~~~~~/third_party/ui_ColorPalette/InputRangeBox'...
Submodule path 'InputRangeBox': checked out '47218224921ee517aadd062a404bb8bbf8b96db6'

$ git submodule update --init toDraggable   <-- update 에서 --init 옵션으로 명령어 하나로 init와 update 가능
Submodule 'toDraggable' (https://github.com/mins01/ui_toDraggable.git) registered for path 'toDraggable'
Cloning into '~~~~~/third_party/ui_ColorPalette/toDraggable'...
Submodule path 'toDraggable': checked out 'ae6d69c41fd85308d9117e534a7e26ceb0233d12

$ git submodule status
 47218224921ee517aadd062a404bb8bbf8b96db6 InputRangeBox (heads/master)
 ae6d69c41fd85308d9117e534a7e26ceb0233d12 toDraggable (heads/master)


최신 버전으로 받고 싶다면
=> --remote 버전을 줘라, 안 주면 추가할 때의 리비전으로 받아진다.
=> 이 경우 메인 .gitmodule 가 변경되면 commit 해줘야한다.
$ git submodule update --remote ui-input-stepper
Submodule path 'ui-input-stepper': checked out '7c7969c1595f9924b34016e84acfe67da65e97b9'


댓글
  • No Nickname
    No Comment
  • 권한이 없습니다.
    {{m_row.m_nick}}
    -
목록형 📷 갤러리형
제목
[기본형] HTML (with 부트스트랩5.3 , jquery 3.7, vue.js)
유용한 리눅스(LINUX) 명령어
[공지] 기술 게시판
3.30
3.31
4.1
4.2
4.3
4.4
4.5
4.6
4.9
4.10
4.11
4.12
4.13
4.14
4.15
4.16
4.17
4.18
4.19
4.20
4.21
4.22
4.23
4.24
4.25
4.26
4.27
4.28
4.29
4.30
5.1
5.2
5.3