0Pricing
Git Advanced: Monorepo, Submodules & Workflows · Lektion

Änderungen mit Subtree Split zurück ins Upstream übertragen

Lernen Sie, wie Sie Änderungen aus einem Subtree extrahieren und mithilfe von git subtree split und push zurück in das ursprüngliche Upstream-Repository übertragen.

Änderungen mit Subtree Split zurück ins Upstream übertragen ist eine kostenlose Git Advanced: Monorepo, Submodules & Workflows-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Git Advanced: Monorepo, Submodules & Workflows-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Git Advanced: Monorepo, Submodules & Workflows-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

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.

Häufig gestellte Fragen

Ist die Lektion „Änderungen mit Subtree Split zurück ins Upstream übertragen“ kostenlos?

Ja — der vollständige Text von „Änderungen mit Subtree Split zurück ins Upstream übertragen“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Git Advanced: Monorepo, Submodules & Workflows-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Git Advanced: Monorepo, Submodules & Workflows-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Änderungen mit Subtree Split zurück ins Upstream übertragen“?

Lernen Sie, wie Sie Änderungen aus einem Subtree extrahieren und mithilfe von git subtree split und push zurück in das ursprüngliche Upstream-Repository übertragen. Du übst Git Advanced: Monorepo, Submodules & Workflows mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Git Advanced: Monorepo, Submodules & Workflows zu starten?

Keine Vorkenntnisse erforderlich. Git Advanced: Monorepo, Submodules & Workflows auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Änderungen mit Subtree Split zurück ins Upstream übertragen“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Git Advanced: Monorepo, Submodules & Workflows-Lektion Code schreiben und ausführen?

Ja. Jede Git Advanced: Monorepo, Submodules & Workflows-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Einführung in Git Subtree
  2. Subtree hinzufügen und zusammenführen
  3. Subtree und Submodule im Vergleich
  4. Änderungen mit Subtree Split zurück ins Upstream übertragen
← Zurück zu Git Advanced: Monorepo, Submodules & Workflows