Branching & Merging
Rust teams typically use trunk-based flow on main with short feat/* branches, optional release/* trains for multi-crate workspaces, and rebase to keep history reviewable.
Busca en todas las páginas de la documentación
Rust teams typically use trunk-based flow on main with short feat/* branches, optional release/* trains for multi-crate workspaces, and rebase to keep history reviewable.
git checkout main
git pull --rebase origin main
git checkout -b feat/billing-tax
# work, commit
git fetch origin
git rebase origin/main
git push -u origin feat/billing-tax
# open PR -> squash merge to mainWhen to reach for this:
# Release train for workspace 2.6.0
git checkout -b release/2.6.0 origin/main
# only bugfixes cherry-picked
git tag v2.6.0
git push origin v2.6.0
# Hotfix from production tag
git checkout -b hotfix/2.5.1 v2.5.0
git cherry-pick <fix-sha>
git push origin hotfix/2.5.1What this demonstrates:
mainmain| Strategy | When |
|---|---|
| Squash merge | One commit per ticket on main |
| Rebase merge | Preserve commit granularity |
| Merge commit | Shared long-lived branches |
When sqlx migrations and binary deploys must align, cut release/* and run full cargo test --all-features before tag.
Cargo.lock conflicts multiply. Fix: rebase daily.main into release/* - pulls unvetted features. Fix: cherry-pick fixes only.main - audit nightmare. Fix: branch protection blocks force push.| Alternative | Use When | Don't Use When |
|---|---|---|
| GitFlow | Heavy release governance | Small continuous deploy team |
| Trunk only | Single binary service | Multi-artifact coordinated release |
| Merge queue | High concurrency monorepo | Tiny team |
Team policy: squash to main is common; rebase locally before merge to keep CI green.
Avoid; one ticket per branch simplifies review and rollback.
Single branch can touch multiple crates; version bumps in one PR when coupled.
Stack versions: This page was written for Rust 1.97.0 (edition 2024), Tokio 1.x, Axum 0.8, serde 1.0, sqlx 0.8, clap 4, and Polars 0.46+.
Revisado por Chris St. John·Última actualización: 16 jul 2026