Skip to content
Versora

Manual

Worktrees

Worktrees

2 min read

On this page

A worktree is an extra working folder of the same repository. Each folder has its own branch checked out, its own changed files and its own staging area. They all share the same history, the same branches and the same remotes, because they use the same .git folder.

With worktrees you review a merge request, fix an urgent bug or run a long build without touching what you're doing in the main folder. There's no need to stash, switch branches and come back later.

Versora treats each worktree as a complete repository, open in a tab of its own. It also links the folders to each other:

  • the tabs of the repository and its worktrees are grouped, with a band of the same color;
  • the graph shows a "// WIP" row for each other worktree with uncommitted changes;
  • you can move changes and commits from one worktree to another;
  • the integrated terminal follows worktree switches;
  • a new worktree can receive the ignored files it needs (such as .env) and run the project's setup commands (such as npm install).

Pages in this area

  • Create and open worktrees: creating from the section's "+", from the branch's or the commit's menu; the WORKTREES section, the grouped tabs, inheriting the graph view, the terminal that switches along and "only this worktree in the graph".
  • Prepare the new worktree: copying the ignored files chosen by .worktreeinclude and running the repository's setup commands.
  • Each worktree's WIP in the graph: the other worktrees' "// WIP" row, the panel with the files and the actions.
  • Move changes and commits between worktrees: sending or bringing over uncommitted changes, cherry-picking into another worktree and moving commits, with undo on both sides.
  • Remove, lock and unlock: removing only the folder, the folder and the branch, or also the branch on the server, with a check of what would be lost.

Quick concepts

TermWhat it is
Main worktreeThe folder where the repository was cloned or created. It can't be removed as a worktree.
Linked worktreeA folder created with git worktree add. Its tab carries the worktree icon, with the tooltip "Worktree of the ‹name› repository".
Checked-out branchA branch can only be checked out in one worktree at a time. Git refuses the same branch in two folders.
detached HEADA worktree created from a commit, without a new branch, is in detached HEAD.

Tip

Use a worktree for each task that lasts more than a few minutes and that you don't want to mix with your current work: an MR review, a hotfix, an experiment. When you're done, remove the worktree and, if you want, the branch along with it.

See also