﻿---
title: "Worktree"
description: "使用 Git Worktree 隔离并行任务的文件系统修改。"
image: "https://kxen.ai/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://kxen.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Worktree

Worktree 为并行 Agent 或任务提供独立工作目录。它解决多个有写权限执行单元同时修改同一文件的问题。

## 产品入口

右侧 Dock 的 Worktree 区域显示当前 Session 绑定的工作树，并提供创建和检查入口。Workspaces 看板用于跨项目查看 Worktree 数量。

## 创建结果

每个 Worktree 绑定:

- 源 Git repository。
- 独立目录。
- 分支或 detached 状态。
- 使用它的 Session、Agent 或 Team member。

创建后，文件工具、Shell、LSP 和 Git 状态都应使用 Worktree 目录，而不是主 Workspace 目录。

## 使用场景

- 两个 execution Agent 并行实现独立功能。
- 审查任务需要固定基线。
- Team member 需要隔离分支。
- 长任务不能影响用户当前工作树。

## Git 边界

Worktree 只提供目录隔离，不自动合并提交。任务完成后仍要检查 diff、运行验证，并由用户或主 Agent决定如何提交和合并。

不要让两个 Worktree 使用同一可写分支。删除 Worktree 前确认没有未提交修改和仍绑定的运行任务。

Source: https://kxen.ai/recovery/worktree/index.mdx
