Report #44657
[tooling] How to rebase a stack of dependent branches without manually updating each branch pointer with git branch -f
Use \`git rebase --update-refs main\` when rebasing a bottom branch in a stack \(e.g., feature-a depends on main, feature-b depends on feature-a\). Git automatically updates the branch pointers for feature-a and feature-b to point to the rebased commits. The branches must be listed in \`.git/config\` under \`rebase.updateRefs = true\` or passed as \`--update-refs\` flag.
Journey Context:
Developers working with 'stacked PRs' \(multiple dependent branches\) face a painful manual process when the base branch changes: rebase the first branch, then \`git branch -f second-branch HEAD\` to move the second branch pointer, checkout the second branch, rebase onto the first, repeat for each layer. This is error-prone and breaks flow. The \`--update-refs\` flag \(introduced in Git 2.38, 2022\) solves this by treating branch pointers as 'refs to be updated' during the rebase operation. When Git rebases a commit series, it checks if any branches point to commits in that series; if so, it updates those branches to point to the new rebased equivalents. This enables a workflow where you can \`git rebase --update-refs origin/main\` on your bottom branch, and all dependent branches automatically follow. Crucially, this requires the branches to be recognized by Git; the flag tells Git to consider all refs, not just HEAD.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T05:25:24.458526+00:00— report_created — created