0Pricing
Git Advanced: Monorepo, Submodules & Workflows · 강의

서브모듈 브랜치 사용

서브모듈 내에서 브랜치를 관리하고 전환하며, 변경 사항을 서브모듈의 원격 저장소로 다시 푸시하는 방법을 학습합니다.

서브모듈 브랜치 사용은(는) CoddyKit의 무료 Git Advanced: Monorepo, Submodules & Workflows 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Git Advanced: Monorepo, Submodules & Workflows 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Git Advanced: Monorepo, Submodules & Workflows 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Branching in Submodules

Git submodules usually point to a specific commit. But what if you need to actively develop inside a submodule?

  • This allows independent feature development.
  • You can contribute changes back to the submodule's own project.
  • It's key for complex projects needing tight integration.

Submodules: Detached HEAD

By default, when you clone a project with submodules, each submodule is checked out to a specific commit. This is called a "detached HEAD" state.

  • It means you're not currently on any named branch.
  • You can view files, but new commits won't automatically belong to a branch.
  • It provides a stable way for the parent repo to reference specific submodule versions.

Navigating into a Submodule

To work with a submodule's branches, you first need to navigate into its directory. Think of it as entering a completely separate Git repository.

Use the cd command to change directories:

# Assume 'my-submodule' is a submodule
cd my-submodule
git status

Checking Submodule Status

Once inside the submodule's directory, you can use regular Git commands to see its status, branches, and current HEAD. This helps you understand its current state.

# Inside the submodule directory
git status
git branch
git log --oneline -1

Switching Submodule Branches

To develop within a submodule, you need to switch from a detached HEAD to a specific branch. Use git checkout just like in any other Git repository.

# Inside the submodule directory
git checkout main
# Or to create and switch to a new branch
git checkout -b new-feature

Committing in a Submodule

Now that you're on a branch, you can make changes, add them, and commit them. These commits are specific to the submodule's repository, not the parent repository.

# Inside the submodule directory
echo "New content" > newfile.txt
git add newfile.txt
git commit -m "Added newfile in submodule"

Pushing Submodule Changes

After committing changes within the submodule, you need to push them to the submodule's own remote repository. This makes your changes available to others.

# Inside the submodule directory
git push origin main
# Or to push a new branch
git push origin new-feature

Updating the Parent Repository

After pushing changes in the submodule, the parent repository still points to the old commit. You need to tell the parent repo to track the new commit.

  • Navigate back to the parent repository.
  • Stage and commit the submodule's change.
# Back in the parent repository
cd .. # Go up one level
git status
git add my-submodule
git commit -m "Updated my-submodule to latest commit"
git push origin main

Submodule Branching Tips

Working with submodule branches requires care and coordination:

  • Communicate: Inform your team if you're actively developing on a submodule branch.
  • Keep parent updated: Always commit the submodule reference change in the parent repo after pushing submodule changes.
  • Avoid direct pushes: Don't push to a submodule's main branch from the parent repo unless absolutely necessary; work inside the submodule itself.

Submodule Branch Quiz

Test your knowledge on managing submodule branches!

Recap: Submodule Branches

In this lesson, we explored how to actively develop within a Git submodule:

  • Navigating into the submodule's directory.
  • Switching from a detached HEAD to a specific branch.
  • Making, committing, and pushing changes in the submodule.
  • Updating the parent repository's reference to the new submodule commit.

This workflow enables independent development and contribution to submodule projects, making your overall project more flexible.

자주 묻는 질문

“서브모듈 브랜치 사용” 강의는 무료인가요?

네 — “서브모듈 브랜치 사용” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 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개 중 1번째 강의입니다.

“서브모듈 브랜치 사용” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Git Advanced: Monorepo, Submodules & Workflows 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Git Advanced: Monorepo, Submodules & Workflows 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 서브모듈 브랜치 사용
  2. 중첩 서브모듈 및 복잡한 구성
  3. 일반적인 서브모듈 문제 및 해결 방법
  4. 서브모듈을 특정 태그 및 커밋에 고정
← Git Advanced: Monorepo, Submodules & Workflows(으)로 돌아가기