Stacks
Merging the stack up to here
10 min read
With an approved stack, the merge has to be done one merge request at a time, bottom to top. After
each merge, the one above needs to be retargeted to main, rebuilt on the new main and pushed
again, and only then can it go in. Done by hand, this takes time and it's easy to make mistakes.
Merge the stack up to here runs this sequence by itself, up to the chosen merge request:
- it checks each merge request beforehand and shows a plan;
- it merges the bottom one, directly or by setting auto-merge, the merge train or the merge queue, depending on the case;
- it waits for the merge to happen;
- it retargets the one above (if the server didn't), rebuilds the stack on
mainand pushes with--force-with-lease; - it repeats with the next one.
If something changes or goes wrong, the process stops and the bar says why and what to do. You can close the app midway: when you reopen the repository, the bar continues where it stopped.
- Branch menu › Branch stack › Merge the stack up to feature/b… (the branch must have a merge request).
- Stack header in the STACKS section: right-click › the same item.
- MERGE REQUESTS section: Stack 2/3 chip or right-click the row › Merge the stack up to !11…
- Merge request review: Merge up to here… button in the stack navigation (tooltip: "Merge the stack, bottom up, up to this merge request.").
- Palette (Ctrl+P): "Merge the stack up to the current branch…" (detail: "Bottom up to feature/b, respecting pipeline, approvals and merge train").
- Palette: "Stack merge: progress" opens the details of a stack merge in progress.
The stack merge needs the local stack, because the restack and the push of each step are done on your branches. Without it, the review button is disabled with the tooltip "Get the stack first: the stack merge updates and pushes the local branches." See Getting a teammate's stack.
When you choose the command, the Merge the stack up to feature/b (2 merge requests)? dialog opens:
"Each merge request goes into main, one at a time, bottom up. With a running pipeline, merge train or merge queue, Versora sets auto-merge and follows along; after each merge, the one above is retargeted (if the server doesn't do it), rebased onto main and pushed with --force-with-lease."
While it checks, you see "Checking each merge request on GitLab…". Then each merge request shows chips and what will happen to it.
| Chip | Meaning |
|---|---|
| "1 approval missing (of 2)" | Required approvals are still missing. |
| "approved (2/2)" | The required approvals were given. |
| "2 approvals" / "no approvals" | Approvals, when the project doesn't require a number. |
| "1 change request" | A reviewer requested changes. |
| "conflicts" | The merge request has conflicts with the target. |
| "draft" | It's marked as a draft. |
| "2 unresolved threads" | There are unresolved threads. |
| "merge train" / "merge queue" | The target uses a merge train (GitLab) or a merge queue (GitHub). |
| "GitHub stack" | GitHub recognizes the stack. |
| "already scheduled" | Auto-merge is already set on the server. |
| Text | When |
|---|---|
| "merge now" | Nothing blocks it: direct merge. |
| "auto-merge when the pipeline passes" | The pipeline is running: Versora sets auto-merge. |
| "joins the merge train (merges when the train pipeline passes)" | The project uses a merge train (GitLab). |
| "joins the merge queue" | The target uses a merge queue (GitHub). |
| "merge through the GitHub stack (in the background)" | GitHub recognizes the stack and merges in the background (merge-async). |
| "already scheduled on the server (Versora follows along)" | Auto-merge or the train was already set. |
| "waits for the result (Pipeline), then merges" | The server is still checking, or the required pipeline hasn't appeared yet. On GitHub, "(Checks)". |
| "blocked (see below)" | Something prevents the merge. |
From the second one on, the text starts with "After !10 is merged: retargeted to main (if the server doesn't do it), rebased onto main and pushed. Then: …". The branches above the last chosen one appear as "Above the last one: feature/c — retargeted and rebased onto main after the merge, not merged."
- If the first merge request is blocked, the plan says "Can't start: !10 is blocked." and the confirmation button is disabled.
- For the others, you see "The merge will stop at !11 if this doesn't change by then:" with the reasons: "The merge request is a draft.", "The merge request isn't open.", "The pipeline failed: auto-merge would never happen. Fix it or retry it first." and the server's blockers (approvals, threads, required pipeline, conflicts).
| Option | What it does | Default |
|---|---|---|
| Squash commits (GitLab) | Combines the commits of each merge request into one, in the merge. Locked when the project fixes the squash setting ("The project fixes the squash setting"). | the project's |
| Merge method (GitHub) | Merge commit, Squash and merge or Rebase and merge, among the ones the repository allows. | Squash and merge, if allowed |
| Delete the source branch on merge (GitLab retargets the one above by itself) | On GitLab, deletes the source branch in the merge itself. | the project's, or checked |
| Delete the source branch after the merge (after retargeting the one above) | On GitHub, deletes the source branch after retargeting the one above. | the project's, or checked |
| Delete the local branches that get merged (Ctrl+Z brings them back) | Deletes the local branch of each merge request that went in. | checked |
The final note reminds you: "Every step is checked again: if a merge request changes midway, the stack merge stops and explains why. Closing the app doesn't lose the progress."
Click Merge 2 merge requests.
During the merge, a bar below the repository bar shows "Stack merge into main: 0 of 2", the merge requests in order and what's happening to the current one:
| Step text | Meaning |
|---|---|
| pending / next | Hasn't started yet / is the next one. |
| merging… | The merge request is being made. |
| auto-merge set | The server merges when the pipeline passes (or the train moves). |
| waiting for GitHub (merging in the background) | GitHub's merge-async is in progress. |
| merged | The merge happened; the ones above still need updating. |
| in main | Merged and the stack updated. |
And what Versora is doing: "Checking on the server…", "Waiting for the result (Pipeline) to merge…", "Updating the stack onto main (rebase and push)…", "Waiting for the running operation to finish…".
While it waits, the bar shows "next check in 20 s". The checks get further apart: 5, 10, 20 and 30 seconds, then every 60. Check now ("Check GitLab now, without waiting") skips the wait. Details opens the full list, and Cancel… ends it (see "Ending" below).
The restack and the push of each step are done in the repository's tab. If you're in another tab when the time comes, that repository's bar shows "Go back to this repository's tab: the restack and push happen there.", and the bar of the tab you're in shows "The stack merge in app is waiting for that tab to update the branches." with Go to the tab.
The bar turns red: "Stack merge stopped at !11 (1 of 2 done):" and the reason. Details shows the title and the full message. The buttons depend on the reason:
| Reason (title in the details) | What happened | What to do |
|---|---|---|
| Blocked | A server blocker appeared (approval, thread, required pipeline). | Resolve it on the server and use Try again. |
| Direct merge refused (405) | "GitLab refused the direct merge of !11 (405). With a mandatory merge train (GitLab 19.3+), the merge only goes through the train…" | Add to the merge train and continue (on GitHub, Add to the merge queue and continue). |
| The pipeline failed | Auto-merge won't happen. If it was the merge train pipeline, the merge request left the train. | Fix or retry the pipeline and use Try again (in the train, this adds the merge request again). |
| Auto-merge canceled | Someone canceled it on the server, or it left the train. | Try again. |
| Merge request closed | "!11 was closed without a merge." | Reopen it on the server or end the stack merge. |
| The merge request changed | The server is at a different commit from the checked one. | Check what came in; Try again accepts the new version. |
| Conflict in the restack | The local update after the merge stopped on a conflict. | Resolve it in the conflict editor, use Continue in the changes panel and then Continue (conflict resolved) in the bar. The merge already done isn't lost. |
| Conflicts on the server | "!11 now has conflicts on the server." | Resolve them on the branch and push; Try again. |
| Branch changed on both sides | The branch changed on the server and here too. | Push or discard the local commits and continue. |
| Branch gone from the server | "feature/b no longer exists on origin: the stack merge stopped here." | Check the server. |
| Push rejected | "The stack push was rejected: …" | Fix the reason (for example, with Update the stack from the server) and Try again. |
| Unexpected target | "!11 targets develop, not the branch that was just merged: Versora leaves it alone." | Point the merge request to main (or check the stack) and Try again. |
| Error | Another failure. | Read the message and Try again. |
At every stop there are Open the review of !11 (in the details), Details and End….
On GitLab 19.3 or newer, a project can require a merge train: the direct merge through the API is
refused with 405. Add to the merge train and continue resends the request with
auto_merge=true, and the merge request goes in when the train pipeline passes. The same refusal
happens if the merge request became a draft, has conflicts or was already merged. See also
Merge train and merge queue.
Cancel… (while running) or End… (when stopped) opens End the stack merge: "Stop the stack merge? 1 of 2 are already in; the others stay as they are."
- If the current merge request is scheduled on the server, the dialog warns: "!11 is still scheduled on the server (auto-merge or merge train): unless you cancel it, it can still merge by itself." and offers Also cancel the auto-merge of !11 on the server (leaves the merge train).
- "Nothing local is undone: the branches stay as they are now."
Click End. The notice "Stack merge ended." confirms it.
The progress is saved in .git/versora-stack-merge/state.json. When you reopen the repository, the
bar shows "The stack merge was left halfway when the app closed: it stopped at !11 (…)." with
Continue, Details and End…. What was already done on the server isn't repeated: each
step is checked again first.
When they've all gone in, the bar turns green: "Stack merge done: !10 and !11 went into main.", with
Close. The branches above the last chosen one are already retargeted and rebuilt on main,
and the navigation in the description is updated.
- Merge: through the GitLab or GitHub API, with the chosen options. With a running pipeline,
merge train or merge queue, it sets auto-merge (
auto_merge=true, or joining the queue). - After each merge: fetch; retargeting the one above, reading the target again first; adopting
what the server rebuilt (GitHub rebases the upper pull requests of a stack of its own); restack
onto the target; push with
--force-with-lease. All of this in a single Ctrl+Z step.
The merges happen on the server and can't be undone from the app. What Ctrl+Z undoes, step by step:
- "Stack update after merging feature/a": the upper branches go back to what they were before that step's restack;
- "Delete branch feature/a": the deleted local branch comes back.
The push done at each step isn't undone on the server.
- "You're on a detached HEAD: check out a branch of the stack."
- "A stack merge is already in progress in this repository.": follow the current one (palette: "Stack merge: progress") or end it.
- "feature/b isn't part of a stack."
- "No merge request yet: feature/c. Create the merge request for each branch before merging the stack.": see Stack merge requests.
- "A rebase is in progress: finish it before merging the stack."
- "Finish the rebase (Continue or Abort in the changes panel) before continuing the stack merge."
- "GitHub couldn't merge #11. Check the pull request in the browser."
Caution
The stack merge uses your account to merge and retarget the merge requests. It respects the project rules (approvals, pipeline, threads), but each merge is real and can't be undone from the app.
- Preferences › Stacks › Navigation in the description decides whether the navigation is written again at the end.
- The token needs permission to merge in the project (
apiscope on GitLab,repoon GitHub).