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
Four branches take part, two in each repository, and git-splice
syncs the monorepo's folder with the upstream branch of the same name.
Rebasing feature onto main is plain Git, and it's one operation
that can be done in either repository. Do it in one of them only, then
carry the result across with git-splice, in this order:
- Rebase via upstream: click "Update
branch" on GitHub, or rebase
featureontomainin a clone of the upstream, thengit splice pullonfeature. The simple default. - Rebase via monorepo:
git rebase mainonfeature, thengit splice push --force. For when GitHub can't rebase, e.g. on a conflict, which you then resolve with the whole monorepo to build and test against. It rewrites the monorepo'sfeatureand overwrites the PR, so it's for branches nobody else pushes to.
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