您的位置:首页 > 手游攻略 > Codex Worktrees 使用

Codex Worktrees 使用

作者:互联网  时间: 2026-09-02 17:21:55  

Worktrees 允许你在 Git 仓库中创建多个工作目录,使你能够并行处理不同的任务而不会相互干扰。


什么是 Worktree?

Git Worktree 是 Git 的一个功能,允许你在同一个仓库中创建多个工作目录。Codex 对 Worktree 提供了原生支持。

使用场景

  1. 并行开发多个功能
  2. 保持主分支干净
  3. 同时进行开发和代码审查

Worktree 让你可以像有多台电脑一样同时工作。

在 Codex 中使用 Worktree

创建 Worktree

创建 Worktree

# 在 Codex 应用中创建 Worktree

# 1. 选择项目

# 2. 点击 "New" -> "Worktree"

# 3. 输入分支名称

# 4. 点击创建

在 Worktree 中运行任务

在创建线程时选择 Worktree 模式:

模式说明
Local在当前项目目录工作
Worktree在独立的 Git worktree 中工作
Worktree 模式创建新的 Git worktree,保持变更隔离。

Worktree 管理

管理 Worktree

# 查看 worktree 列表

git worktree list

# 创建新的 worktree

git worktree add ../feature-branch -b feature-branch

# 删除 worktree

git worktree remove ../feature-branch


最佳实践

  1. 为每个功能或修复创建独立的 Worktree
  2. 使用描述性的分支名称
  3. 完成后及时清理不需要的 Worktree
Worktree 是并行开发的利器,特别适合大型项目。

最新游戏

更多

Copyright©2010-2019. All rights reserved | 波波三国游戏官网|[email protected]

备案编号:湘ICP备2022015115号-4