9148c358d0
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
142 lines
4.7 KiB
Markdown
142 lines
4.7 KiB
Markdown
---
|
|
id: wiki-2026-0508-submodules
|
|
title: Submodules
|
|
category: 10_Wiki/Topics
|
|
status: verified
|
|
canonical_id: self
|
|
aliases: [Git Submodules, git submodule]
|
|
duplicate_of: none
|
|
source_trust_level: A
|
|
confidence_score: 0.9
|
|
verification_status: applied
|
|
tags: [git, submodules, monorepo, vendoring]
|
|
raw_sources: []
|
|
last_reinforced: 2026-05-10
|
|
github_commit: pending
|
|
tech_stack:
|
|
language: bash
|
|
framework: git
|
|
---
|
|
|
|
# Submodules
|
|
|
|
## 매 한 줄
|
|
> **"매 repo-in-repo with pinned commit"**. Git submodule 매 외부 repository 의 specific commit 의 reference 의 host repo 안 의 nest. 매 2026 perspective: monorepo / package manager (pnpm workspaces, npm workspaces) 의 대부분 의 use case 의 replace, 매 vendoring binary asset, plugin SDK, firmware blob 의 niche 의 survive.
|
|
|
|
## 매 핵심
|
|
|
|
### 매 동작 model
|
|
- 매 host repo 의 `.gitmodules` file 의 url + path 의 list.
|
|
- 매 host repo 의 tree object 의 submodule path 의 gitlink (commit SHA) 의 store — 매 file 의 X.
|
|
- 매 `git clone` 의 default 의 submodule 의 fetch X — 매 `--recursive` 또는 `git submodule update --init`.
|
|
- 매 detached HEAD state 의 submodule 의 default — 매 branch tracking 의 explicit opt-in.
|
|
|
|
### 매 typical pitfall
|
|
- 매 host commit 의 update X 의 submodule pointer 의 stale.
|
|
- 매 force-push 의 submodule remote 의 host 의 SHA 의 missing — fetch fail.
|
|
- 매 nested submodule 의 `--recurse-submodules` 의 forget 의 partial checkout.
|
|
- 매 CI 의 shallow clone 의 submodule 의 not 의 init.
|
|
|
|
### 매 응용
|
|
1. Vendoring third-party C/C++ library (FFmpeg, OpenSSL).
|
|
2. Sharing firmware blob 의 multiple device repo.
|
|
3. Plugin / theme SDK 의 host application 의 embed.
|
|
4. Documentation site 의 example code 의 separate repo 의 pin.
|
|
|
|
## 💻 패턴
|
|
|
|
### Add submodule
|
|
```bash
|
|
git submodule add https://github.com/org/lib.git vendor/lib
|
|
git commit -m "Add vendor/lib submodule"
|
|
```
|
|
|
|
### Clone with submodules
|
|
```bash
|
|
git clone --recurse-submodules https://github.com/org/host.git
|
|
# 또는 매 already-cloned repo
|
|
git submodule update --init --recursive
|
|
```
|
|
|
|
### Update submodule to latest
|
|
```bash
|
|
cd vendor/lib
|
|
git fetch && git checkout v2.5.0
|
|
cd ../..
|
|
git add vendor/lib
|
|
git commit -m "Bump vendor/lib to v2.5.0"
|
|
```
|
|
|
|
### Pull host + sync submodule pointers
|
|
```bash
|
|
git pull --recurse-submodules
|
|
git submodule update --init --recursive
|
|
```
|
|
|
|
### Track branch (not detached)
|
|
```bash
|
|
git submodule add -b main https://github.com/org/lib.git vendor/lib
|
|
git config -f .gitmodules submodule.vendor/lib.update merge
|
|
git submodule update --remote --merge
|
|
```
|
|
|
|
### Remove submodule (2026 way)
|
|
```bash
|
|
git submodule deinit -f vendor/lib
|
|
git rm -f vendor/lib
|
|
rm -rf .git/modules/vendor/lib
|
|
git commit -m "Remove vendor/lib submodule"
|
|
```
|
|
|
|
### Foreach run command across all
|
|
```bash
|
|
git submodule foreach --recursive 'git status'
|
|
git submodule foreach 'git checkout main && git pull'
|
|
```
|
|
|
|
### CI shallow + submodule
|
|
```yaml
|
|
# GitHub Actions 매 example
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
fetch-depth: 0
|
|
```
|
|
|
|
## 매 결정 기준
|
|
| 상황 | Approach |
|
|
|---|---|
|
|
| JS/TS shared lib | pnpm workspace 또는 npm workspace |
|
|
| Polyglot monorepo 의 source share | git subtree (history merged) |
|
|
| Binary asset 의 pin (firmware, large model) | submodule |
|
|
| Third-party C/C++ vendoring | submodule 또는 vcpkg/Conan |
|
|
| Plugin SDK 의 host 의 embed | submodule (pinned SHA) |
|
|
| Multi-language CI 의 partial checkout | sparse-checkout + submodule |
|
|
|
|
**기본값**: 매 JS/TS 의 monorepo 의 workspaces 의 use, 매 submodule 의 binary / cross-ecosystem vendoring 의 reserve.
|
|
|
|
## 🔗 Graph
|
|
- 부모: [[Version Control]]
|
|
- 변형: [[Monorepo]]
|
|
|
|
## 🤖 LLM 활용
|
|
**언제**: 매 binary asset 또는 cross-language vendor lib 의 pin 의 specific upstream commit 의 reproducibility 의 require.
|
|
**언제 X**: 매 JS/TS 의 shared package — 매 workspace 의 strictly superior. 매 frequently-edited shared code — 매 subtree 또는 monorepo 의 prefer.
|
|
|
|
## ❌ 안티패턴
|
|
- **Submodule 의 active dev**: 매 submodule 안 의 daily edit 의 host pointer 의 forever-out-of-date — 매 monorepo 의 promote.
|
|
- **Force-push 의 upstream**: 매 host repo 의 referenced SHA 의 lose — 매 fetch fail forever.
|
|
- **`git submodule update` 의 forget**: 매 host pull 후 의 stale submodule 의 confusing diff.
|
|
- **Nested submodule 의 5+ level**: 매 cognitive overhead 의 explode — 매 flatten 의 prefer.
|
|
- **Submodule 의 source-of-truth treat**: 매 fork 의 publish 의 X 의 host-only patch 의 lose.
|
|
|
|
## 🧪 검증 / 중복
|
|
- Verified (Git docs `git-submodule(1)`, Pro Git Book Ch. 7.11).
|
|
- 신뢰도 A.
|
|
|
|
## 🕓 Changelog
|
|
| 날짜 | 변경 |
|
|
|---|---|
|
|
| 2026-05-08 | Phase 1 |
|
|
| 2026-05-10 | Manual cleanup — submodule lifecycle, CI, anti-patterns |
|