Skip to content
Versora

Manual

Stacks

Branch stacks (stacked merge requests)

5 min read

On this page

A big change is hard to review in a single merge request. With a stack, you split the change into small branches, one on top of the other. Each branch has its own merge request, and each merge request targets the branch below it, not main. The reviewer reads one part at a time, and you keep working on the upper part while the lower one is in review.

main ← feature/a (!10 → main) ← feature/b (!11 → feature/a) ← feature/c (!12 → feature/b)

In this example:

  • feature/a starts from main, and merge request !10 targets main;
  • feature/b starts from the tip of feature/a, and !11 targets feature/a, so it shows only the commits of feature/b;
  • feature/c starts from feature/b, and !12 targets feature/b.

Versora takes care of the laborious parts of a stack:

  • it redoes the rebase of all the branches at once when the lower one changes;
  • it pushes them all in a single push, with --force-with-lease;
  • it creates each merge request with the right target already set;
  • it retargets the upper merge requests when the lower one goes into main.

Terms used in this section

TermMeaning
Parent, or branch belowThe branch the branch was built on. Its merge request targets the parent.
Branch aboveThe branch built on top of this one.
Main branchThe target of the lowest branch in the stack, usually main. The STACKS section shows "on main".
BaseThe parent's commit the branch was last built on. It's where the branch's own commits start.
RestackRedoing the rebase of each branch onto its parent's new tip. In Versora, it's "Restack".
PositionThe branch's place in the stack, counting from the bottom: 2/3 is the second of three.

Where the stack is stored

The stack lives only in the repository's local config (.git/config). Nothing goes into the project files or to the server. Each stacked branch gets two keys in its section:

INI
[branch "feature/b"]
    versora-parent = feature/a
    versora-base = 3f9c2e1a…
  • versora-parent: the branch's parent.
  • versora-base: the parent's commit where the branch's commits start. It's what lets the rebase be redone without replaying the parent's commits, even after an amend on the parent or a squash on the server.

Since the keys live in the branch.<name> section, git itself carries them along when you rename the branch and deletes them when you delete the branch.

Tip

Since the stack doesn't leave your machine, a teammate doesn't see it through the config. They can bring the same stack from the server through the merge requests: see Getting a teammate's stack.

Stacks Versora recognizes

Besides the stacks created by Versora itself, the app reads, read-only:

SourceHow it's recognizedTooltip on the STACKS section row
Versorabranch.<name>.versora-parent keys(none: it's the default source)
git-towngit-town-branch.<name>.parent key"Parent recorded by git-town."
glab stackfiles in .git/stacked/<title>/"glab stack."
Implicitopen merge requests whose target is another branch with an open merge request"Implicit stack: the merge request targets another branch with an open merge request."

A glab stack stack appears in the STACKS section with the title it has there. The others appear with the name of the lowest branch.

Recording the stack in Versora

Stacks that weren't created by Versora work for restacking, pushing and creating merge requests. Some operations, such as "Remove from the stack", only apply to recorded stacks. To save a stack from another source in Versora's config:

  • Branch menu › Branch stack › Record the stack in Versora.
  • Palette (Ctrl+P): "Record the stack in Versora" (detail: "Saves the implicit stack (MRs), the glab or git-town stack in the local config").

The notice "Stack recorded in the repository's local config." confirms it. After that, the stack stays valid even when the merge requests are closed. With the stack already recorded, the palette shows the command as unavailable: "the stack is already recorded".

The recording goes into Ctrl+Z as "Record the stack of feature/b": undoing it deletes from the local config the keys the recording saved (each branch's parent and base), and the stack is seen again as it was before, through its source. No branch or commit changes.

What you can do with a stack

TaskPage
Start a stack, stack a branch that already exists, remove from the stackCreating a stack
Read the STACKS section and the marks in the graphSTACKS section and marks in the graph
Redo the rebase of all the branches after changing one of themRestacking
Push all the branches in a single pushPushing the stack
Create the merge requests and keep the "Stack: !10 → !11 → !12" navigationStack merge requests
Carry on after the lower one went into mainSyncing the stack
Reorder, fold, split and view the diffChanging the stack structure
Bring in what teammates pushed to the stack's branchesUpdating the stack from the server
Build someone else's stack locallyGetting a teammate's stack
Merge all the merge requests, bottom to topMerging the stack up to here

Requirements

  • Git 2.38 or newer for restacking in a single rebase, with update-ref. With an older git, the restack uses a fallback path, and the result is the same (see Restacking). In that case, the git version bar at the top of the window lists "restacking in a single rebase (2.38)" among the unavailable features (see Warnings).
  • GitLab or GitHub registered with a token in Git servers for everything that involves merge requests. Without a server, the stack works locally only: create, restack and push. In that case, the notice is "No GitLab or GitHub set up for this remote: the stack works locally only (create, restack and push)." See Git servers.

Preferences › Stacks has the "Navigation in the description" option and a "How it works" box, which says whether this machine's git supports update-ref in a rebase. The palette opens the page with "Stack preferences". There's no company policy key for stacks.

See also