Rebasing a feature branch
A feature branch was pushed, so upstream has it as a PR. Then upstream's
main moved on, and the monorepo's main pulled that in. The PR is now
behind main: GitHub says "This branch is out-of-date with the base
branch". To bring it up to date, feature is rebased onto main.
m adds lock.txt:
The rebase strategies
git-splice syncs with the upstream branch of the same name. Rebasing
feature onto main is a separate Git operation: do it in one repository
only, then carry the result across with git-splice:
| Strategy | How to use it | When to use it |
|---|---|---|
| Via upstream | Click "Update branch" on GitHub, or rebase in a clone of the upstream, then git splice pull on feature. | The simple default. |
| Via monorepo | On feature, run git rebase main, then git splice push --force. | When GitHub can't rebase, resolve conflicts with the whole monorepo to build and test. Rewrites the monorepo's feature branch and overwrites the PR; use only when nobody else pushes to them. |
Don't mix the strategies: a rebase in the monorepo, then a pull of the PR that was never rebased, sends the old commits back to the PR.
Output
rebase-setup.bash builds this state:
$ build_scenario scenario_feature_branch_behind_default_branch
$ git -C "$UPSTREAM" log --graph --format=%s main feature
* m: bump dep
| * b: feature change
|/
* k: seed
git-splice compares feature with upstream's feature only, and
those match. That the PR is behind main is a matter between the two
branches of each repository:
$ git splice status
On branch feature
up to date vendor/a