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

Subtree Split으로 변경 사항을 업스트림에 다시 푸시

서브트리 내부에서 변경한 사항을 추출하고 git subtree split과 push를 사용하여 원래 업스트림 저장소로 다시 푸시하는 방법을 학습합니다.

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

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

Two-Way Subtree Workflows

Subtree is not just for pulling code in. One of its strengths is the ability to contribute changes back to the original project. This makes subtree a genuine two-way integration tool.

The key command is git subtree push, powered internally by git subtree split.

What 'split' Does

git subtree split walks your history and produces a synthetic branch containing only the commits that touched the subtree's prefix, rewritten as if that folder were the repo root.

This is what makes the changes mergeable back upstream.

Recap: Adding a Subtree

Assume you added an upstream library under vendor/widget earlier. Now you have made improvements there and want to share them.

git subtree add --prefix=vendor/widget \
  https://example.com/widget.git main --squash

Creating the Split Branch

Run split to create a branch with just the subtree's history rebased to the prefix root.

git subtree split --prefix=vendor/widget -b widget-upstream

Inspecting the Split

Check out the split branch and confirm its files live at the root, not under vendor/widget. This proves the rewrite worked.

git log --oneline widget-upstream
git ls-tree --name-only widget-upstream

Pushing the One-Step Way

You can split and push in a single command. git subtree push does the split internally and pushes the result to the upstream remote and branch.

git subtree push --prefix=vendor/widget \
  https://example.com/widget.git contrib-branch

Opening a Pull Request

Push to a feature branch on a fork you control, then open a pull request upstream. Your subtree commits appear as ordinary commits on that project, ready for review.

Keeping Splits Fast

On large histories, split can be slow because it re-walks commits. Subtree caches rewrites; passing --rejoin writes a merge commit so future splits start from there.

git subtree split --prefix=vendor/widget --rejoin

Avoiding Mixed Commits

Split works cleanly only when commits are scoped. A commit touching both the subtree and unrelated app code becomes awkward upstream. Keep subtree changes in their own focused commits.

When to Push Back

Push upstream when your fixes are general-purpose and the maintainers accept contributions. For private, repo-specific tweaks, keep them local and never push them back.

Pulling Their Acceptance Back

After upstream merges your contribution, pull it back into the subtree so your superproject and the original project converge again, closing the round trip.

git subtree pull --prefix=vendor/widget \
  https://example.com/widget.git main --squash

Quick Check

Test your understanding of subtree split and push.

Recap

You learned the two-way subtree workflow: split isolates subtree commits into a prefix-rooted branch, push sends them upstream in one step, --rejoin speeds up repeated splits, and keeping commits focused makes upstream contribution clean.

자주 묻는 질문

“Subtree Split으로 변경 사항을 업스트림에 다시 푸시” 강의는 무료인가요?

네 — “Subtree Split으로 변경 사항을 업스트림에 다시 푸시” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Git Advanced: Monorepo, Submodules & Workflows 강의 전체를 잠금 해제할 수 있습니다. Git Advanced: Monorepo, Submodules & Workflows 강의에는 총 4개의 강의가 포함되어 있습니다.

“Subtree Split으로 변경 사항을 업스트림에 다시 푸시”에서 뭘 배우나요?

서브트리 내부에서 변경한 사항을 추출하고 git subtree split과 push를 사용하여 원래 업스트림 저장소로 다시 푸시하는 방법을 학습합니다. 브라우저에서 직접 실행하는 실습 코드로 Git Advanced: Monorepo, Submodules & Workflows을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Git Advanced: Monorepo, Submodules & Workflows을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Git Advanced: Monorepo, Submodules & Workflows은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.

“Subtree Split으로 변경 사항을 업스트림에 다시 푸시” 강의는 얼마나 걸리나요?

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

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

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

이 강의의 모든 강의

  1. Git Subtree 소개
  2. Subtree 추가 및 병합
  3. Subtree와 Submodule 비교
  4. Subtree Split으로 변경 사항을 업스트림에 다시 푸시
← Git Advanced: Monorepo, Submodules & Workflows(으)로 돌아가기