중첩된 Repository를 관리하기 위해 GIT에서 제공하는 기능
git submodule init
subtree는 프로젝트 dependency가 있어서 합쳐야 할 때
submodule은 루트단위로 관리할 필요가 없고 폴더별 nested하고 싶을 때, 따로 관리해도 될 때 dependency가 없을 때
서브모듈 루트 디렉토리의 경로와 원격 저장소의 주소를 관리
- 서브모듈을 Slave Repository
- Slave Repository의 변경사항이 있는 경우 Master 및 Slave 각각 두 번의 Commit
Commit은 반드시 Slave → Master의 순서
- Slave Repository는 Master Repository가 바라볼 때 Abstraction되는 방식으로 관리됩니다. 즉, Master Repository에서 Commit을 할 때 Slave Repository의 변화는 1개 변경사항으로 축약되어 추적(Tracking)
[GIT] Submodule (Nested Repository) 사용하기 - ECE - TUWLAB
GIT을 사용하여 버전관리를 하다 보면, GIT 저장소(Repository) 안에 또 다른 저장소를 만들어서 사용하고 싶은 경우가 있습니다. 규모가 어느 정도 되는 프로젝트에서 전체 프로그램을 기능별로 모듈화해서 작성하고 각각 따로 버전관리를 하고자 하는 경우가 이에 해당하는 상황일 것입니다. 모듈별로 따로 버전관리를 할 수 있다면, 재사용과 이식성 면에서도 크게 도움이 되기 때문이죠.
https://www.tuwlab.com/ece/26011
![[GIT] Submodule (Nested Repository) 사용하기 - ECE - TUWLAB](https://www.notion.so/image/https%3A%2F%2Fwww.tuwlab.com%2F.%2Ffiles%2Fattach%2Fimages%2F2382%2F011%2F026%2Fb870adfc79d2fbf16e444483fbdc2a19.png?table=block&id=8ba8944e-ed27-483b-8481-2b3a1c528de8&cache=v2)
How to use git subtree to add local repo?
Say I have a dir that is already a git repo "sub", now I want it to be a subtree of my newly created super directory "sup". I've searched the document, but all the tutorials are about adding a rem...
https://stackoverflow.com/questions/37775092/how-to-use-git-subtree-to-add-local-repo
Git subtree를 활용한 코드 공유
서비스를 개발하다 보면 코드를 공유해야 하는 일이 생긴다. 백엔드를 마이크로 서비스 구조로 개발하면 API 리스펀스, 각종 데이터 모델에 같은 타입을 사용해서 일관성을 유지해야 한다. 그리고 프론트엔드 웹을 데스크탑, 모바일로 분리해서 개발한다면 데이터 모델뿐만 아니라 컴포넌트 및 다양한 유틸리티 모듈을 함께 사용할 필요가 생긴다.
https://blog.rhostem.com/posts/2020-01-03-code-sharing-with-git-subtree

Seonglae Cho