All docs

Branch, rewind and worktrees

Keep parallel sessions apart with worktrees, ship work as a PR or a merge, and fork or rewind a conversation.

Branches and worktrees

Every session shows its machine, folder and branch at the top left. The branch menu lists your branches, and also has New Branch…. Switching branch changes the folder itself, so it affects every session working in that folder. For that reason the branch entries and New Branch… are unavailable while any session in the folder, this one included, is working. New Session in Worktree… stays available.

A worktree gives a session its own folder and branch, while history and remote stay shared with your main repository. Use one whenever two sessions work in the same repo.

To start a session in a worktree:

  1. On the new session screen, open the branch menu and choose New Worktree…. In an existing session, use the location menu and choose New Session in Worktree….
  2. Enter a Branch name, or leave it empty to name it from your first message.
  3. Choose what it starts From: the default branch, the current branch or another branch.
  4. Check Project setup. It shows the repo's setup command and symlinked folders. To change them, click Repository Settings…, which opens the repo's page in Home › Repos (see Repos and shared memory). There, Setup command is a command such as pnpm install that runs before your first message, and Symlinked folders are folders such as node_modules that are linked to the main checkout instead of copied.
  5. Click Create, then send your first message. The worktree is created when you send it.

Files that git ignores, such as .env, aren't copied. Add a .worktreeinclude file to the repo to copy chosen ignored files.

Worktrees live under ~/.beydock/worktrees on the machine that runs the session. You can change the location for each device in the Worktree location box on its device page in Home. Under Settings › Sessions › Worktrees, set a Worktree branch prefix and choose whether to Archive sessions when their pull request is merged or closed. BeyDock checks pull requests every 5 minutes, and an archived session's worktree is removed only if it's clean.

Cleaning up

When you archive or delete a worktree session, a clean worktree is removed silently. If it has uncommitted changes or unpushed commits, a card lists them and asks Keep Worktree or Remove Worktree. Removing deletes the folder and its uncommitted changes, and the branch is kept if it has commits. If a worktree folder is missing, the session offers Restore Worktree. The device page lists all worktrees and has Remove Clean Worktrees.

Ship your work

A band above the message box shows the repo, the changes against the base branch, and the next step:

  • Create PR opens a pull request on GitHub with gh, the GitHub command line tool, which must be installed. When everything is committed, BeyDock pushes the branch and opens a draft PR itself. Use the menu for Create Ready PR. When there are uncommitted changes, BeyDock asks the agent to commit and open the PR, and the menu also has Create Draft PR.
  • Commit and Push asks the agent to commit and push.
  • View PR #N (or Draft PR #N) opens an existing PR.
  • Merge into the base branch merges locally with --no-ff. It is in the Create PR menu, and it is offered for a session's own worktree once everything is committed. If the merge conflicts, BeyDock undoes it so your target branch stays clean, and offers Ask Agent to Resolve.

Fork and rewind

Hover a message or a reply to see its actions:

  • Rewind appears on your last message. It removes that message and the reply, and puts your message back in the box so you can edit it. /rewind does the same.
  • Fork from here starts a new session from that point and leaves the original as it is. /fork forks from the last reply.
  • Fork into new worktree does the same in its own worktree and carries your uncommitted changes over.

Providers differ:

  • Claude and Z.ai can rewind both the conversation and the files. The confirmation offers Rewind Conversation and Files or Rewind Conversation Only. Z.ai runs on the Claude Code engine, so it behaves like Claude here.
  • Codex and Command Code can fork and rewind, but don't restore files. Files they changed stay as they are.
  • Antigravity, OpenCode and Cursor can't cut a conversation, so Rewind and Fork are unavailable and the commands say why.

On an SSH host, git, worktrees and files are on that host.