Git Worktree in Zed Editor
Zed is a high-performance code editor built in Rust with native Git integration. It works well with git worktree for parallel development workflows. This guide covers how to set up worktrees with Zed, leverage its multi-pane layout, and work around current limitations.
Zed's Git Integration
Zed includes built-in Git support that shows inline blame annotations, gutter indicators for changed lines, and a Git status panel. When you open a worktree directory in Zed, it detects the git repository automatically by following the .git file that links back to the main repository's git directory.
Zed correctly identifies the current branch, tracks file changes, and shows diffs for linked worktrees just as it does for regular repositories. The editor's status bar displays the branch name of the worktree you are working in, so you always know which branch you are editing.
Because Zed is designed for speed, opening a worktree directory is nearly instantaneous regardless of project size. There is no indexing delay when switching between worktrees, which makes it a natural fit for workflows where you frequently move between branches.
Opening Worktrees in Zed
You can open any worktree in Zed the same way you open any project directory. Zed recognizes the linked worktree and provides full Git functionality:
# Create a worktree for a feature branch
git worktree add ../my-project-feature feat/dark-mode
# Open it in Zed from the terminal
zed ../my-project-feature
# Or open the main project in one window and the worktree in another
zed .
zed ../my-project-featureEach Zed window operates independently, so you can have your main branch in one window and a feature branch in another. File searches, project-wide find and replace, and the file tree are all scoped to the worktree you have open.
You can also use Zed's command palette (Cmd+Shift+P on macOS) to open a new project window and navigate to a worktree directory. This is useful when you want to quickly jump into a different worktree without leaving Zed.
Multi-Pane Workflow
Zed's multi-pane layout is particularly useful when comparing code across worktrees. While each worktree needs its own Zed window (since panes within a window share the same project root), you can arrange multiple Zed windows side by side for an effective comparison workflow.
# Set up a two-worktree development workflow
git worktree add ../my-project-stable release/v2.0
git worktree add ../my-project-next feat/v3-migration
# Open both in Zed windows
zed ../my-project-stable &
zed ../my-project-next &
# Arrange windows side by side using your window manager
# macOS: use Split View or a tool like Rectangle
# Linux: use your tiling WM (i3, Sway, etc.)Within each window, you can use Zed's split panes to view multiple files from the same worktree. Combined with the integrated terminal, you can run builds, tests, and git commands for each worktree without leaving the editor.
# Use Zed's integrated terminal in each worktree window
# to run branch-specific commands:
# In the stable worktree window:
npm run build
npm test
# In the feature worktree window:
npm install # install any new dependencies
npm run dev # start dev server on a different portCurrent Limitations
While Zed handles worktrees well for most workflows, there are a few limitations to be aware of:
No Built-in Worktree Management
Zed does not provide UI elements for creating, listing, or removing worktrees. All worktree management must be done through the terminal, either Zed's integrated terminal or an external one. You cannot browse worktrees or switch between them from within the editor's Git panel.
Single Project Root per Window
Each Zed window is associated with a single project root directory. You cannot open multiple worktrees as separate roots within the same window. This means you need one window per worktree, which can increase memory usage if you have many worktrees open simultaneously.
Extensions and Language Server State
Each Zed window runs its own language server instances. When you open multiple worktrees of the same project, each window will start separate language server processes. For large projects with heavy language servers (like TypeScript or Rust Analyzer), this can consume significant system resources.
Tips for Zed Users
Use a Consistent Directory Layout
Keep all worktrees as siblings of your main project directory. This makes it easy to open them from the terminal and keeps your project file tree predictable. A naming convention like project-branchname helps you quickly identify which worktree is which.
Leverage Zed's Speed for Quick Reviews
Zed's fast startup time makes it ideal for quickly opening a worktree to review changes, then closing it. Unlike heavier editors that take seconds to load a project, Zed opens a worktree almost instantly. Use this to your advantage for quick code reviews across branches.
Create a Shell Alias for Worktree + Zed
Combine worktree creation and Zed opening into a single command:
# Add to your ~/.zshrc or ~/.bashrc
zwt() {
local branch="$1"
local dir="../$(basename $(pwd))-$(echo $branch | tr '/' '-')"
git worktree add "$dir" -b "$branch" && zed "$dir"
}
# Usage: create a worktree and open it in Zed in one step
zwt feat/new-dashboardClean Up Worktrees Regularly
Since each worktree window runs its own language servers and processes, close Zed windows for worktrees you are no longer actively using. Then remove the worktree to free disk space and keep your project directory tidy. Run git worktree prune periodically to clean up stale references.
Zed's speed and lightweight design make it an excellent editor for git worktree workflows. Open each worktree in its own window, use the integrated terminal for worktree management, and take advantage of Zed's fast startup for quick cross-branch reviews. For more editor integrations, see the IDE integration overview.