Worktree sets
A worktree set is a directory on a workstation that holds a git worktree of each of up to eight sources, all on one branch, for sessions to work in.
A worktree set is a directory on a workstation that holds a git worktree of each of one to eight of the workstation’s sources, all on one branch. A terminal session or an agent session names a set, and starts in it. You use a set to give one task its own branch in every repository it touches. Several sessions can work in the same set.
To start, create a set and a session that works in it:
rl worktreeset create tls-floor --workstation my-box \
--path sessions/ringleader/tls-floor --branch fix/tls-floor \
--source ringleader --source infra
rl terminalsession create fix --workstation my-box --worktree-set tls-floorThe panes of fix start in the ringleader tree, once the workstation has made both trees. If
that is all you need, you are done. The sections below say where the trees live, what makes one
wait, and what keeps a tree after the set is gone.
Where the trees live
A set’s path names the directory that holds its trees. A path that is not absolute is read from
the login user’s home, and you write it without ~. Each source’s tree is at
<path>/<source>, so the set above puts trees at sessions/ringleader/tls-floor/ringleader and
sessions/ringleader/tls-floor/infra under the home directory. Ringleader adds no directory of
its own around the path.
The source names are the sources[].name entries of the workstation’s configuration, and a
set holds each one once. The first source is where a session starts. A set of one source still
uses <path>/<source>.
How Ringleader makes a set
The workstation makes each tree from the source’s clone when it picks the set up, and the set’s
phase goes from Pending to Ready. When the branch already exists in a source’s clone,
Ringleader checks it out and continues it, which is how you pick work up again. A branch that
does not exist yet starts from the ref the source declares, or from the remote’s default branch
when the source declares none. Just before the workstation makes the branch, it fetches that ref
from origin and starts the branch at the commit it fetched.
The workstation sets the new branch to track the remote branch it started from, such as
origin/main. So git status in the tree says how far the branch is ahead of or behind the
remote branch, and git pull needs no branch name. When the source’s ref is a tag, the
new branch tracks nothing. Ringleader does not change what a branch that already existed tracks.
When the fetch succeeds, the workstation also moves the clone’s copy of the remote branch forward
to the fetched commit. A source whose ref is a tag has no such copy. The new branch then starts
level with the remote branch, so git status in a new tree says the branch is up to date. If the
remote branch was rewritten on origin, such as by a force push, the workstation leaves the copy
where it was. Then git status in the new tree can say the branch is behind the remote branch or
has diverged from it.
The source’s own checkout shares that copy, so git status there may now say its branch is
behind. The count is correct: origin has commits that the checkout’s branch does not, and the
fetch changed no file in the checkout.
If the fetch fails or times out, the workstation still makes the branch and its tree. The branch
then starts at the commit the clone already has for that ref, which can be older than origin’s.
The clone’s copy of the remote branch stays where it was. So git status in the tree can say the
branch is up to date while origin has newer commits.
You create a set from the command line. The desktop app and the web console also create one
when you tick Make a worktree set for this session in the New session dialog. They give
that set deletionPolicy: DeleteWhenUnused, so Ringleader deletes it after no session has named
it for 10 minutes. A set made with rl worktreeset create stays until you delete it.
When a tree waits
A tree waits, and the set stays Pending, in these cases:
- Its branch is already checked out in another tree of the same clone, including the clone’s own checkout.
- A branch beside it blocks it.
fixcannot exist next tofix/x. - Another set, or a tree Ringleader is keeping, holds its path.
- Its path would sit inside another tree or inside a source’s own checkout. The tree is then
refused.
A session that names the set waits too, and its status says why. Ringleader does not resolve these conflicts for you: change the branch or the path, or remove what is in the way.
What a set shares and keeps
Any number of terminal and agent sessions can name one set at the same time, and nothing keeps their edits apart. Deleting a session never removes trees. An agent session that borrows its workstation from a workstation pool cannot name a set.
Deleting a set removes each tree that holds no unsaved work, ignored files included, and removes the set’s directory once it is empty. A tree that holds unsaved work stays on the workstation, and the branch always stays in the source’s clone. Ringleader keeps a tree when it holds any of these:
- Uncommitted edits or untracked files.
- A file flagged
assume-unchangedorskip-worktree. - A git operation, such as a rebase, that is still in progress.
- A detached HEAD on a commit that no branch contains.
- An ignored file that git cannot delete, such as one in a read-only directory.
- A submodule that holds any of these, or a commit that no remote branch contains.
- Files in a submodule directory that git never initialized.
Other ignored files do not keep a tree. A kept tree holds its path, so a new session that asks for the same path waits until the tree is gone. A set created again on the same branch and path takes over a kept tree as it stands. Deleting the workstation deletes its sets.
Create a set
Run rl worktreeset create with the workstation, a path, a branch and each source:
rl worktreeset create tls-floor --workstation my-box \
--path sessions/ringleader/tls-floor --branch fix/tls-floor \
--source ringleader --source infraThe command writes the set and returns. The workstation then makes the trees. Read the phase with
rl worktreeset get tls-floor, and each tree’s state with rl worktreeset get tls-floor -o yaml.
The workstation, the path and the branch cannot change after you create the set.
Use a set from a session
Name the set when you create a session. The set must be on the same workstation and belong to you.
rl terminalsession create fix --workstation my-box --worktree-set tls-floorA terminal session takes --worktree-set or --workdir, not both. Its panes start in the set’s
first tree, once the workstation has made all of the set’s trees. rl agentsession create takes
the same --worktree-set flag. The agent starts in the set’s first tree too, unless you give it
a --workdir. A session’s set cannot change after you create it.
Terminal sessions and
Agent sessions cover the rest of each
command.
Change a set’s sources
You can change a set’s sources after you create it. Edit the set, and change the sources list.
The order matters, because the first source is where sessions start.
rl worktreeset edit tls-floorKeep a set that the app created
To stop Ringleader deleting a set after its sessions close, change its deletionPolicy to
Retain. Open the set in your editor:
rl worktreeset edit tls-floorChange the deletionPolicy line under spec from DeleteWhenUnused to Retain, or add the
line if the set has none:
spec:
deletionPolicy: RetainSave the change before the 10 minutes pass. From then on the set stays until you delete it.
List the worktrees a workstation keeps
List the trees a workstation holds while they wait or because they hold unsaved work:
rl workstation list-worktrees my-boxThe table has the columns PATH, SOURCE, SESSION and STATE. -o json prints the same
rows as JSON. A tree can be in one of these states:
| State | Meaning |
|---|---|
being made | The workstation is making the tree, and it arrives by itself. |
blocked | Something on the workstation has to change first. |
refused | The session’s worktree entry cannot be met as written. |
A tree whose session was deleted is listed as blocked, because it holds something nobody saved,
and only the session’s uid is known for it. A made tree of a set that still exists does not
appear here. It shows on the set’s status. When the workstation holds nothing, the command says
so. The list comes from the workstation’s status, so the command needs no connection to the
workstation.
Remove a kept worktree
Remove a tree that the workstation keeps, after the command shows what removing it destroys:
rl workstation remove-worktree my-box sessions/ringleader/tls-floor/infraGive the path as list-worktrees shows it. The command connects to the workstation over SSH, so
it needs a workstation this device can reach. It asks the workstation what the tree holds, and
prints the tree’s path, its source and its session. Then it prints one of these:
The workstation found nothing in it that git has not saved.Removing it destroys:and a list of what is lost: a git operation in progress and its state, a commit that no branch contains, edits to a file that git is told to ignore, the changes in a submodule, and one line for each changed file, withand N morewhen the list is long.
Removing a worktree cannot be undone
The command then asks Remove it?. Answer no, and it prints Not removed. and exits 1. With no
terminal to ask on, the command prints the list and exits 2 until you pass --yes. On success it
prints removed and the path. The workstation removes the tree on its next pass, usually within a
minute, and only when no session on it still declares the tree and no agent is running in it.
If the workstation reports no tree at that path, the command says so and names
rl workstation list-worktrees. If the workstation’s agent is too old to remove a worktree, the
command says it can once the agent updates.
Delete a set
Delete a set to release its trees:
rl worktreeset delete tls-floorRingleader refuses while a terminal session names the set, and names up to five sessions. Delete
those sessions first. It also refuses while an agent session that names the set is running or has
a restart that has not run. For each tree, the command prints that Ringleader removes it once it
holds no unsaved work, and that rl workstation list-worktrees lists it until then. The branch
stays in the source’s clone.
Next steps
- Terminal sessions: open a set’s trees in panes that keep running.
- Agent sessions: run a coding agent in a set.
- WorktreeSet: every field and phase of a set.
- Terminal session and worktree set commands: every command and flag.