Skip to main content

Create and Link Worktrees

Creating worktrees from forge data: from an issue, from a pull request, several at once from a selection, plus automatic issue and PR detection and linking an existing worktree by hand.

Reviewed

Creating worktrees from issues

The quickest way to start on an issue is to create a worktree straight from it:

  1. Click the issues count in the toolbar to open the issues panel
  2. Find or search for the issue you want to work on
  3. Click Create Worktree on the issue row
  4. The create worktree dialog opens with the issue pre-linked

What gets auto-populated

  • Branch name: generated from the issue title and number (for example feature/issue-42-add-dark-mode). The prefix is inferred from issue labels and title keywords: bugfix/ for bugs, docs/ for documentation, and so on.
  • Worktree path: filled in from your configured path pattern
  • Base branch: defaults to main or master

Every field is editable before you create. If a branch name already exists, Daintree auto-increments it (feature/issue-42-add-dark-mode-1).

Assign to self

When your forge identity is known, the dialog shows an Assign to me toggle. Turn it on and the issue is assigned to you as the worktree is created. The preference is remembered across sessions.

Run a recipe on create

If you have recipes configured, you can pick one to run when the worktree is created, so the agents you want are launched with the worktree.

Tip
Use the {{number}} variable in recipe prompts to insert the issue or PR number at launch time. One recipe then works for both issue-based and PR-based worktree creation.

Creating a worktree from a PR

You can create a worktree directly from a pull request. Each open PR row has a Create Worktree action, on hover or via the ··· menu.

The dialog opens in a checkout mode tailored for PRs. It shows a PR info banner and pre-fills the branch name from the PR's head branch. When that branch has already been fetched locally, Daintree uses it as the checkout target. When it hasn't, Daintree fetches the PR head ref first. Only if that fetch fails does it show a warning and disable the create button, so you don't accidentally branch off main instead.

Note
Fork PRs work. Because the head is fetched by PR ref rather than by branch on a remote you may not have, a PR from a fork checks out the same way as one from a branch in the repository, from a single row and from the bulk flow alike. Older versions of Daintree disabled the create action for fork PRs; that restriction is gone.

Bulk worktree creation

When you need worktrees for several issues or PRs at once, the bulk flow saves you from doing them one at a time. Selection starts in the forge panel, so this is where the flow begins.

Selecting items

Hover the state icon on any row and it turns into a checkbox. Click to select that item. Once one is selected, every row switches to checkboxes so you can keep going. Use Shift+click to select a range between the last selected item and the one you click. When a search is active, Select all and Select unassigned (issues only) shortcut buttons appear in the panel header.

Closing and reopening the panel within the same project keeps your selection intact, so a quick glance elsewhere doesn't lose it. Switching projects clears the selection, and so does dismissing the bulk-create dialog, whether you finish, cancel, or press Escape.

The bulk action bar

As soon as you select one or more items, a floating bar slides up from the bottom of the panel. It shows the number selected, a Create Worktrees button, and an X to clear the selection. The X stays responsive even while the bar is animating out.

Reviewing before creating

Clicking Create Worktrees opens a dialog listing every selected item with its planned branch name. Items that can't be created are dimmed with a badge explaining why:

  • Closed or Merged: the issue or PR is no longer open
  • Has worktree: a worktree already exists for this item
  • No branch info: the PR is missing a head branch reference

The dialog also has an Assign to me toggle (issues only) and an optional recipe picker if you want agents to launch in each new worktree.

Every branch name is shown before anything is created

Creation progress

Once you confirm, Daintree creates the worktrees three at a time. Each item shows its own state: a spinner while in progress, a checkmark when done, or a warning icon if something went wrong. A progress bar and summary track the overall count. The concurrency limit sits at three because git worktree add --no-track avoids the .git/config.lock contention that used to block parallel operations, while the forge's own rate limiter stays the primary throttle.

Transient errors (git lock files, secondary rate limits, connection blips) are retried on a wall-clock budget, not an attempt count. Each item keeps retrying with exponential backoff (starting at 3 seconds, capped at 30, or 60 for the assignment call) until a five-minute per-item ceiling elapses. Five minutes is chosen deliberately: a GitHub secondary rate limit usually clears inside that window, and one that hasn't is a multi-hour penalty no in-process retry could outlast. Permanent errors fail immediately rather than burning the budget.

When creation finishes

When the batch completes, the dialog shows a summary. If any items failed, a Retry Failed button re-queues only those and leaves already-created worktrees alone. Done closes the dialog and switches to the last worktree created successfully. A system notification confirms the result and how many worktrees were created.

Automatic issue detection

Daintree parses branch names to detect a linked issue. Five patterns are tried in priority order:

PatternExample branch
issue-42feature/issue-42-fix-header
issue/42 or issues/42issues/123
#42fix-#88-crash
gh-42bugfix/gh-15-login-bug
jira-42jira-904-import

Long-lived branches are skipped outright: a branch named main, master, develop, staging, production, release or hotfix (or prefixed with any of them followed by a slash) never matches, so a release/2026-04 branch doesn't pick up issue 2026. If the branch name yields nothing, Daintree tries the same patterns against the worktree's folder name.

When an issue is detected, the worktree card shows an issue badge with the number and title, and tracks the issue's open and closed state.

Manual issue linking

If a worktree already exists and you want to link it to an issue after the fact, you can attach one by hand. This covers the case where you started work before an issue was filed, or where branch-name detection didn't match the right issue.

  1. Right-click a worktree card, or click the ··· button in the card header, to open the context menu
  2. Select Attach to Issue... (or Change Issue... if an issue is already linked)
  3. The Attach Issue dialog opens with a search field and filter tabs
  4. Search by title or issue number, and use the Open, Closed, or All tabs to filter by state
  5. Select an issue from the list to attach it

The Attach Issue dialog

  • The search field filters by both title and issue number, with a short debounce so results update as you type
  • State filter tabs (Open, Closed, All) let you attach closed issues too. The filter resets to Open each time the dialog opens
  • Keyboard navigation uses and to move through the list, and Enter to attach the selected issue
  • An already-attached issue appears in the list with an attached badge

Detaching an issue

To remove a linked issue, open the same dialog through Change Issue.... A Detach Issue button appears in the footer when an issue is currently attached.

Note
Manual attachments take precedence over automatically detected issues from branch-name patterns. If you detach a manually linked issue and the branch name still matches a detection pattern, that auto-detected issue reappears on the card.

Effect on the worktree card

When any issue is linked to a worktree, whether attached by hand or detected from the branch name, the worktree card updates:

  • The issue title becomes the card's primary headline, replacing the branch name at the top
  • The branch name moves to a secondary row below the headline
  • Clicking the issue title opens the issue in your browser
  • Hovering the issue title shows a card with title, description summary, labels, and state, fetched on hover

Persistence

Issue associations are stored in Daintree's local settings, not in your git repository. They survive app restarts, and they're cleaned up when you delete the worktree. Each worktree can have one attached issue at a time.

Automatic PR detection

When you switch to a worktree, Daintree checks whether its branch has an open pull request. The root worktree is excluded from branch-name matching, so it won't pick up a spurious PR badge when its branch happens to match a PR's head. When a PR exists:

  • The worktree card shows a PR badge with the number and state: open, draft, merged, or closed. When a remote is connected but no PR exists, the badge reads "No PR".
  • The badge carries the same freshness, rate-limit and circuit-breaker glyphs as the toolbar counts, so a paused or stale badge says so rather than looking current.
  • Hovering fetches PR detail into a rich hover card.
  • Clicking the badge opens the PR in your system browser. If no credential is stored for the provider, the click routes you to Settings > Code Forge instead.