Skip to content
Versora

Manual

Worktrees

Create and open worktrees

9 min read

On this page

This page covers how a worktree comes in: creating the folder, opening the tab and working in it. Versora also links the new worktree to the repository it came from. The tabs are grouped, the graph inherits the hidden and solo branches, and the terminal follows the folder switch.

Create a worktree with "New worktree…"

It's the most complete path. You choose where the worktree starts from (the current branch, another branch or the current commit), whether it gets a new branch, where the folder goes and whether it opens in a tab.

Where to find it

  • Left panel: the + button in the WORKTREES section header (tooltip "New worktree…").
  • Palette (Ctrl+P): "New worktree…" (detail: "Another working folder of this repository, on a branch").

Step by step

  1. Open the repository in a tab and click the + in the WORKTREES section.
  2. In the New worktree window, choose in Start from:
    • "‹branch› (current branch)": the branch checked out in this tab;
    • "Current commit (‹sha›)": the commit you're on;
    • any other local branch on the list.
  3. In New branch, type a name (for example fix/erro-no-login) to create the branch right away. If you leave it empty, the worktree uses the chosen branch itself. If you chose the current commit and left it empty, the worktree is in detached HEAD.
  4. Check Folder to create it in. The default is the folder that contains the repository, so the worktree sits next to it.
  5. Check Folder name. The default is the repository's name with -wt at the end (for example loja-web-wt).
  6. Leave Open in a new tab checked to start working in the worktree right afterwards.
  7. Click Create worktree.
OptionWhat it doesDefault
Start fromThe branch or commit the worktree starts from.The current branch (or the current commit, in detached HEAD)
New branchCreates a branch with that name at the chosen point and checks it out in the new folder.Empty: uses the chosen branch (or detached HEAD on the commit)
Folder to create it inThe folder in which the worktree's folder will be created.The folder that contains the repository
Folder nameThe worktree folder's name.<repository>-wt
Open in a new tabOpens the worktree in a tab as soon as it's created. Unchecked, the app only says "Worktree created at ‹folder›."Checked

Create a worktree from the branch's or the commit's menu

When you're already looking at the branch or the commit in the graph, the context menu creates the worktree straight from it.

Where to find it

  • The commit's menu (right-click a commit in the graph): Create worktree from this commit…
  • A local branch's menu (in the left panel or on the graph label): Create worktree from › ‹branch› or Create worktree from › this commit. The item with the branch's name is disabled on the current branch, because it's already checked out here.
  • A remote branch's menu: Create worktree from › origin/‹branch› or › this commit.

Step by step

  1. Right-click the commit or the branch and choose the item above.
  2. The Create worktree window says where it starts from ("A second working folder for this repository, starting at ‹point›. It opens in a new tab.").
  3. In Create in, choose the folder where the worktree will live.
  4. Check Folder name. The default is <repository>-<branch>, with the slashes in the branch's name replaced with hyphens (feature/login becomes loja-web-feature-login), or <repository>-<short sha> for a commit.
  5. In New branch (optional), type a name if you want a new branch. Empty, the worktree uses the branch itself or, for a commit, is in detached HEAD.
  6. Click Create worktree. The worktree's tab opens on its own.

Tip

When creating from a remote branch (origin/feature/login), fill in New branch (optional) with the local name (feature/login). Without it, git leaves the worktree in detached HEAD on the remote's commit, and a commit made there isn't on any branch.

What Versora does in git

Both windows run the same command, in the active tab's repository:

bash
# with a new branch
git worktree add -b fix/erro-no-login ../loja-web-wt main

# without a new branch: uses the chosen branch (or detached HEAD, if it's a commit)
git worktree add ../loja-web-wt feature/login

The repository gets an entry in .git/worktrees/ and the new folder gets a .git file pointing to it. No existing branch changes. With New branch, a branch is created at the chosen point.

Right afterwards, Versora:

  1. copies the source repository's graph filter to the new worktree (see "The graph view comes along", below);
  2. opens the Prepare the worktree window, if the repository has a .worktreeinclude that picks files or saved setup commands. Without any of that, the window doesn't even show up. See Prepare the new worktree.

The same goes for worktrees created from a merge request, through the in-app review (see MR review).

How to undo

Creating a worktree doesn't go into Ctrl+Z. To go back, remove the worktree (and the branch, if it was created just for it): see Remove, lock and unlock.

Caveats and messages

  • "The branch ‹branch› is already checked out here or in another worktree. Give it a new branch name.": git doesn't allow the same branch in two folders. Fill in New branch or choose another starting point.
  • Create inside this worktree? ("The folder ‹folder› is inside this worktree's folder: it will show up as untracked files here unless it's in .gitignore."): you chose a folder inside the repository itself. Click Create anyway only if that folder is in .gitignore. The usual thing is to create the worktree next to the repository.
  • "The folder already exists: ‹folder›": there's already a folder with that name at the destination. Change the Folder name.
  • "Worktree created at ‹folder›." (or "Worktree created at ‹folder›", from the commit/branch menu): it worked.

The WORKTREES section

The left panel's WORKTREES section lists the repository's other worktrees. The number next to the title counts how many there are. With none, it shows "No other worktrees. Create one from a commit or branch menu."

Each row shows the folder's name and the checked-out branch (or "detached HEAD"), plus the markers:

MarkerMeaning
●3The worktree has 3 uncommitted changes (tooltip: "3 uncommitted changes").
PadlockThe worktree is locked. The tooltip shows "Locked" or "Locked: ‹reason›".
folder missingThe folder no longer exists (tooltip: "This worktree's folder no longer exists. Remove it to clean up the record.").

Hover to see the full path and the tooltip "Double-click to open in a tab". A double-click opens the worktree in a tab (or activates the tab, if it's already open).

A worktree's menu

Right-click a row in the section:

ItemWhat it does
Open in a tabOpens or activates the worktree's tab.
Show in file explorerOpens the folder in File Explorer.
Copy pathCopies the folder's path ("Path copied").
Open the terminal in this worktreeOpens the worktree's tab with the integrated terminal in its folder.
Bring the changes over here…Brings the uncommitted changes from that worktree to the current tab. See Move changes and commits.
Send the changes from here to there…Takes the uncommitted changes from the current tab to that worktree. Disabled if the current tab has no changes.
Prepare (.worktreeinclude and setup)…Opens the prepare window for that worktree. See Prepare the new worktree.
Lock worktree… / Unlock worktreeSee Remove, lock and unlock.
Remove this worktree…Removes the worktree's folder, with a check of what would be lost.
Remove worktree and delete branch ‹branch›…Removes the folder and the local branch together. It only shows up if the worktree is on a branch.

The items that depend on the folder are disabled when it's missing.

In the branch menu

When a branch is checked out in another worktree, its menu gets three items:

  • Open this branch's worktree (‹folder›);
  • Remove this branch's worktree…;
  • Remove worktree and delete branch ‹branch›….

Grouped tabs

The repository's tabs and those of its worktrees sit side by side, with a band of the same color underneath. A linked worktree's tab carries the worktree icon, with the tooltip "Worktree of the ‹name› repository". In the vertical tabs, the worktrees show up indented under the repository's tab.

Grouping changes the real order of the tabs. That's why Ctrl+1 to Ctrl+9, Ctrl+Tab and the vertical tabs follow the same order you see. Dragging a tab out of the group takes the whole group.

To turn it off: Preferences › Worktrees › Grouped tabs, the "Group worktree tabs of the same repository" checkbox.

The graph view comes along

A new worktree inherits the graph view of the repository it was created from: the hidden branches and the solo branches. That applies to every way of creating it (the section's "+", the branch's and the commit's menu, and the worktree opened from an MR). There are two adjustments:

  • the worktree's own branch is never hidden;
  • if the source had solo branches, the worktree's branch goes into solo too. Without that, the new graph wouldn't show its own work.

After that, each tab has its own filter. Changing the filter in one tab doesn't change the other. See Graph search and filters.

A terminal that switches along

Each worktree has its own integrated terminals, open in its folder. With the terminal open, switching to the tab of another worktree of the same repository shows that worktree's terminal. If it doesn't have a terminal yet, the app opens a new one in its folder. The keyboard focus goes along when it was in the terminal.

This only touches the app's own terminals. To turn it off: Preferences › Worktrees › Terminal, the "The terminal follows worktree switches" checkbox. See also Integrated terminal.

Only this worktree in the graph

In a repository with many branches, a worktree's graph can show only what belongs to it: the history of the checked-out branch and of that branch's upstream.

Where to find it

  • The target button in the WORKTREES section header. The tooltip says "Show only this worktree in the graph (‹branch› and its upstream)" when it's off and "Show all branches in the graph" when it's on.
  • Palette (Ctrl+P): "Graph: only this worktree" (detail: "Only the history of ‹branch› and its upstream") or "Graph: show all branches".

Step by step

  1. In the worktree's tab, click the target button in the WORKTREES header.
  2. The graph then shows only the worktree's branch and its upstream, in solo.
  3. Click again to go back to the filter you had before.

The scope follows the worktree: if you check out another branch in that tab, the graph then shows the new branch. Changing the filter by hand (a branch's eye, solo or the palette's "Show all branches in the graph" command) ends the scope and keeps the filter you chose.

Caveats and messages

  • "This worktree is in detached HEAD: the scope needs a branch.": the button is disabled without a branch. Check out a branch first.
  • Preferences › Worktrees ("Tabs, graph and terminal" group):

    SettingCheckboxDefault
    Grouped tabsGroup worktree tabs of the same repositoryOn
    Worktree WIP in the graphShow a WIP row for each worktreeOn
    TerminalThe terminal follows worktree switchesOn

    These three settings apply to the whole app, on this computer. The setup commands, on the same page, apply per repository: see Prepare the new worktree.

  • The administrator can hide the Worktrees page in Preferences or make it read-only, with the preferences_hidden and preferences_locked keys and the worktrees id. See Policy keys.

See also