서브모듈을 특정 태그 및 커밋에 고정
서브모듈이 가리키는 커밋이나 태그를 정확히 제어하여 재현 가능한 빌드와 신중하게 검토할 수 있는 의존성 업데이트를 구현하는 방법을 익힙니다.
서브모듈을 특정 태그 및 커밋에 고정은(는) CoddyKit의 무료 Git Advanced: Monorepo, Submodules & Workflows 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Git Advanced: Monorepo, Submodules & Workflows 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Git Advanced: Monorepo, Submodules & Workflows 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Submodules Pin Commits, Not Branches
A common misconception: a submodule tracks a branch. In reality, the superproject records a specific commit SHA for each submodule. Branches only matter when you choose to update.
This pinning is what makes submodule-based builds reproducible across machines and time.
Inspecting the Pinned Commit
See exactly which commit each submodule is locked to with git submodule status. The leading SHA is the recorded pin.
git submodule status
# +a1b2c3d libs/engine (v2.3.0-4-ga1b2c3d)Reading the Status Prefix
- (space) — submodule is at the pinned commit
- + — checked-out commit differs from the pin
- - — submodule is not initialized
- U — merge conflicts in the submodule
Pinning to a Specific Tag
To pin to a released tag, enter the submodule, check out the tag, then commit the new pointer in the superproject.
cd libs/engine
git fetch --tags
git checkout v2.4.0
cd ../..
git add libs/engine
git commit -m 'Pin engine to v2.4.0'Pinning to an Exact SHA
Sometimes you need a commit between releases. Check out the exact SHA inside the submodule, then record it in the superproject.
cd libs/engine
git checkout 9f8e7d6
cd ../..
git add libs/engine
git commit -m 'Pin engine to 9f8e7d6 hotfix'Detached HEAD Is Normal Here
Checking out a tag or SHA puts the submodule in detached HEAD. That is expected and correct for pinning. You only attach to a branch when you intend to develop inside the submodule.
Optional Branch Tracking
You can record a preferred branch in .gitmodules so git submodule update --remote knows what to follow. The pin still wins until you explicitly update.
[submodule "libs/engine"]
path = libs/engine
url = https://example.com/engine.git
branch = stableControlled Updates with --remote
To advance a submodule to the latest of its tracked branch, use --remote. Review the diff before committing the new pin so the bump is deliberate.
git submodule update --remote libs/engine
git diff --submodule
git add libs/engine && git commit -m 'Bump engine'Enforcing Pins in CI
Builds should fail if a submodule drifts from its pin. A CI guard checks that the checked-out SHA matches the recorded one.
git submodule status | grep '^+' && echo 'Submodule drift!' && exit 1Why Deliberate Pinning Matters
Accidental submodule bumps are a frequent source of mysterious build breaks. Treating each pin change as a reviewable, intentional commit keeps your dependency surface predictable and auditable.
Reverting a Bad Pin
If a pin update breaks the build, revert it like any other change: the superproject commit that moved the pointer can be undone, snapping the submodule back to its previous SHA.
git revert <pin-bump-commit>
git submodule update --init libs/engineQuick Check
Test your understanding of submodule pinning.
Recap
You learned that submodules pin commit SHAs, how to read git submodule status prefixes, how to pin to a tag or exact SHA, why detached HEAD is normal, optional branch tracking, controlled --remote updates, and CI drift enforcement. Deliberate pinning keeps advanced submodule setups reproducible.
자주 묻는 질문
“서브모듈을 특정 태그 및 커밋에 고정” 강의는 무료인가요?
네 — “서브모듈을 특정 태그 및 커밋에 고정” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Git Advanced: Monorepo, Submodules & Workflows 강의 전체를 잠금 해제할 수 있습니다. Git Advanced: Monorepo, Submodules & Workflows 강의에는 총 4개의 강의가 포함되어 있습니다.
“서브모듈을 특정 태그 및 커밋에 고정”에서 뭘 배우나요?
서브모듈이 가리키는 커밋이나 태그를 정확히 제어하여 재현 가능한 빌드와 신중하게 검토할 수 있는 의존성 업데이트를 구현하는 방법을 익힙니다. 브라우저에서 직접 실행하는 실습 코드로 Git Advanced: Monorepo, Submodules & Workflows을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Git Advanced: Monorepo, Submodules & Workflows을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Git Advanced: Monorepo, Submodules & Workflows은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“서브모듈을 특정 태그 및 커밋에 고정” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Git Advanced: Monorepo, Submodules & Workflows 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Git Advanced: Monorepo, Submodules & Workflows 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 서브모듈 브랜치 사용
- 중첩 서브모듈 및 복잡한 구성
- 일반적인 서브모듈 문제 및 해결 방법
- 서브모듈을 특정 태그 및 커밋에 고정