Skip to main content

Rebase via monorepo

In the same state, feature is rebased onto main in the monorepo, and the result replaces the PR:

  1. On main: git splice pull. Done already: p brought in m.
  2. On feature: git rebase main.
  3. git splice push --force.

Rebase via monorepo, with the monorepo main and feature on the left and the upstream main and feature on the right: 1, on main, git splice pull from the upstream main; 2, on feature, git rebase main; 3, git splice push --force to the upstream feature

The PR ends up as "Update branch" with a rebase on GitHub would leave it. --force overwrites whatever upstream's feature has, so it's for a PR nobody else pushes to.

Output​

rebase-setup.bash builds this state:

$ build_scenario scenario_feature_branch_behind_default_branch

The monorepo, a with two children, p on main and b on feature, which is H; upstream, k, which is U(H), with two children, m on main and b prime, which is T, R and feature

The rebase copies b onto p as c:

$ git rebase -q main
$ git log --graph --format=%s
* b: feature change
* p: pull the dependency update
* a: clone vendor/a
* initial commit

The monorepo, a, p on main and c on feature, with H at c; upstream, k with two children, m on main, which is U(H), and b prime on feature, which is T; R is c prime, dashed, on top of m

$ git splice status
On branch feature

ahead 2, behind 1 vendor/a

A plain push refuses: upstream has a commit this branch lacks. That it's b', the copy of b from before the rebase, is for you to know:

$ git splice push vendor/a
!! vendor/a: upstream has commits this branch lacks
!! Failed: vendor/a
[1]
$ git splice push --force vendor/a
ok vendor/a: pushed 125a49b to feature
$ git -C "$UPSTREAM" log --graph --format=%s feature
* b: feature change
* m: bump dep
* k: seed

The monorepo, a, p on main and c on feature, with H at c; upstream, k, m on main, which is U(H), and c prime on top of m, which is T, R and feature

$ git splice status
On branch feature

up to date vendor/a