본 문서는 Design-Core 저장소를 프로젝트에 서브모듈로 추가하여 사용하는 방법에 대한 가이드를 제공합니다.
(이미 등록되어 있는 경우 넘어가세요)
$ git submodule add https://github.com/ohmy0418/Design-Core.git source/frontend/nuxt-styled/assets/style-core
$ git submodule add <원격 저장소의 주소> <등록할 저장소의 폴더 경로>
command + shift + .
를 눌러주면, 숨김 파일 확인이 가능하고, .gitmodules
파일 Open
아래 이미지와 같이 숨김 파일이 열리고, 해당 파일을 클릭하면 submodule 정보를 확인 및 수정이 가능하다.
[submodule "source/frontend/src/assets/style-core"]
path = source/frontend/src/assets/style-core
url = https://github.com/ohmy0418/Design-Core.git
branch = dev
Image
(submodule을 처음 받아온 경우 실행합니다.)
다른 작업자가 등록한 submodule을 포함한 레포를 받아오면 서브모듈 디렉토리가 비어있기 때문에 아래 명령어로 서브모듈 내용을 가져온다.
$ git submodule init
// 현재 브랜치의 최근 업데이트 커밋 해쉬를 받아옴
$ git submodule update
// Submodule 레파지토리의 가장 최신 커밋 해쉬를 받아옴
$ git submodule update --remote
서브모듈의 변경사항을 업데이트 해오는 명령어
// 해당 레파지토리의 최신 버전을 가져올 때 사용하는 명령어
$ git submodule update
// 서브모듈 브랜치의 가장 최신 버전을 가져올 때 사용하는 명령어
$ git submodule update --remote
From https://github.com/ohmy0418/Design-Core
bb8195d..4f903ac main -> origin/main
Submodule path 'source/frontend/src/style-core': checked out '4f903acf48e0a5502830eeda15bdd15f6a48c60e'
루트 디렉토리 경로에서 아래와 같이 작성하면 원하는 서브모듈만 콕 찝어 업데이트 할 수 있다.
git submodule update --remote **source/frontend/src/assets/style-core**
그렇지만, 서브모듈이 코어 디자인 하나만 등록된 프로젝트라면, git submodule update --remote
명령어를 사용해도 된다.
업데이트 한 서브모듈의 커밋 내역을 확인
git diff --submodule
위 명령어를 입력하면 새로운 화면에 아래와 같이 서브모듈로부터 업데이트 해 온 커밋명이 출력된다.
Submodule source/frontend/src/style-core bb8195d..4f903ac:
> Merge pull request #72 from ohmy04180/dev (커밋)
(END)
변경 내용을 확인했고 이상이 없다면 커밋을 남기고 원격 저장소에 Push 한다. 커밋을 작성할 때는 프로젝트를 수정한 내용과 서브모듈을 업데이트한 내용이 섞이지 않도록, 업데이트 즉시 커밋을 남기는 것이 좋다.
커밋 메시지는 Update 프리픽스를 사용하고 어떤 커밋을 머지 했는지도 함께 기록 한다.
git commit -m "update: style-core(IDC@3c8b371)"
git commit -m "update: style-layout(IDL@4736839)"
fatal: Needed a single revision
Unable to find current origin/master revision in submodule path 'source/frontend/src/assets/style-core'
git config -f .gitmodules submodule.source/frontend/src/assets/style-core.branch dev