Skip to content
Versora

Manual

Stacks

Syncing the stack after the merge

5 min read

On this page

When the merge request of the bottom branch goes into main, the stack needs three adjustments:

  • the upper merge requests, which targeted the merged branch, now target main;
  • the upper branches are rebuilt on main, without replaying the commits that were already merged;
  • the merged branch leaves the stack and, if you want, is deleted.

With a squash on the server, the commits of feature/a become a new commit on main, and an ordinary rebase of feature/b would try to reapply the old commits, with conflicts. Versora avoids that: it redoes the rebase starting from the old tip of feature/a, so only the commits of feature/b itself are reapplied.

How Versora notices the merge

The bottom branch counts as "merged" when:

How it went inText in the dialog
The merge request was merged"!10 was already merged into main."
The commits are in the target (ordinary merge)"The branch's commits are already in main (merge)."
There are equivalent commits in the target"The branch's commits already have equivalents in main (a single-commit squash, or a rebase or cherry-pick on the server)."

When that happens, the STACKS section shows the green bar "!10 (feature/a) was merged into main.", with the Sync button, and the branch row gets the merged chip.

Where to find it

  • STACKS section: Sync button on the stack's green bar.
  • Branch menu › Branch stack › Sync the stack (feature/a was merged)…
  • Palette (Ctrl+P): "Sync the stack…" (detail: "feature/a was merged into main"). While the bottom one hasn't been merged, the detail is "When the bottom branch is merged (squash included)" and the command is unavailable: "the bottom branch hasn't been merged".

Step by step

  1. Click Sync.
  2. Read the steps in the Sync the stack: feature/a was merged dialog:
    • how the branch went in;
    • "• !11 will target main (through the API).";
    • "• Rebase feature/b onto main, starting from the old tip of feature/a: the commits that were merged aren't replayed.";
    • if feature/a had local commits that weren't in the merge request: "Heads up: feature/a has local commits that weren't in the merged merge request. They're left out of the branches above.";
    • if you're on feature/a: "You're on feature/a: feature/b will be checked out.";
    • "Afterwards, "Push the stack" force pushes the replayed branches."
  3. Adjust the options (table below) and click Sync.
  4. The bar shows "Syncing the stack (feature/a was merged)…".
  5. At the end, the notice "Stack synced: feature/a left the stack and the branches above were replayed. Push the stack to update the merge requests." with the Push the stack button. With no branches above, the notice is "Stack synced: feature/a left the stack.".
  6. Click Push the stack so the server gets the rebuilt branches.
OptionWhat it doesDefault
Retarget the merge requests above to mainChanges the target of the upper merge requests through the API. It only appears when one of them still targets the merged branch.checked
Delete the local branch feature/aDeletes the merged branch at the end.checked
Also delete origin/feature/aDeletes the branch on the server. It only appears if it still exists there.unchecked

What Versora does

  1. Retargets the upper merge requests, before any deletion. Deleting the target of an open merge request would close it on GitHub or leave it without a target on GitLab. Before changing it, Versora reads each one's target again: if the server already retargeted it, Versora leaves it alone.

  2. Records the new parent of the upper branches: the local branch that tracks origin/main, if there is one, or main itself. The base becomes the old tip of feature/a.

  3. Removes feature/a from the stack (if it was recorded by Versora).

  4. Rebuilds the upper branches with the same restack (a single git rebase -i, as in Restacking):

    bash
    # for each branch right above the merged one
    git config branch.feature/b.versora-parent main
    git config branch.feature/b.versora-base <old tip of feature/a>
    # and the restack of feature/b (and the ones above it) onto main
    
  5. Deletes the local branch, if checked (git branch -D feature/a), and, if checked, the remote one (git push origin --delete feature/a).

  6. Updates the navigation in the descriptions, if it's turned on.

Conflicts

A conflict stops in the conflict editor, as in the restack. Continue in the changes panel goes on, and the requested deletions happen when the rebase finishes. Abort leaves the branches as they were. The merge requests that were already retargeted stay retargeted: that was done on the server, before the rebase.

How to undo

Ctrl+Z undoes "Sync stack (feature/a)": the upper branches go back to what they were and the deleted local branch comes back. When the sync stopped on a conflict and the deletion happened afterwards, it goes into undo as "Delete branch feature/a".

These don't come back with Ctrl+Z:

  • the target of the retargeted merge requests (change it in the browser, if needed);
  • the branch deleted from the server.

Caveats and messages

  • "feature/a hasn't been merged yet.": the merge of the bottom one hasn't happened yet.
  • "An operation is in progress (merge, rebase…): finish or abort it before syncing the stack.": finish the stopped operation first.
  • "Couldn't retarget !11: …": the server refused the target change. Nothing local was touched. Check the token's permission and try again.
  • "feature/a got new commits during the operation and wasn't deleted: check it and delete it by hand if needed.": someone committed to the branch while the operation was stopped on a conflict.

Tip

On GitLab 19.1 or newer, with the "Delete source branch after merge" option turned on in the merge request, the server itself retargets the upper merge request. Versora notices and doesn't retarget it again; the sync is still useful to rebuild the local branches.

  • Preferences › Stacks › Navigation in the description decides whether the navigation is written again after the sync.
  • The token must be able to edit the merge requests to retarget them.

See also