git-wt
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesegit-wt — Git Worktree Manager
git-wt — Git工作区管理器
git-wt~/.git-wt/<repo>/<name>/.gitignoregit-wt~/.git-wt/<repo>/<name>/.gitignorePrerequisites
前提条件
git-wtgit wt --versionIf not installed, ask the user to install it from: https://github.com/kuderr/git-wt#install
git-wtgit wt --version如果未安装,请让用户从以下地址安装:https://github.com/kuderr/git-wt#install
Commands Reference
命令参考
Create a worktree
创建工作区
bash
git wt new # Auto-named (e.g., swift-jade)
git wt new my-feature # Named
git wt new -b main hotfix # Fork from specific branch
git wt new --copy-env experiment # Copy .env* files into worktree
git wt new --no-branch scratch # Detached HEAD (no branch created)bash
git wt new # 自动命名(例如:swift-jade)
git wt new my-feature # 指定名称
git wt new -b main hotfix # 从指定分支创建
git wt new --copy-env experiment # 将.env*文件复制到工作区
git wt new --no-branch scratch # 分离HEAD状态(不创建分支)Navigate to a worktree
导航到工作区
bash
cd $(git wt path <name>) # Jump into worktree
git wt open <name> # Open in Cursor/VS Code/$EDITORbash
cd $(git wt path <name>) # 进入工作区
git wt open <name> # 在Cursor/VS Code/$EDITOR中打开List worktrees
列出工作区
bash
git wt list # Worktrees for current repo
git wt list-all # Worktrees across ALL reposbash
git wt list # 当前仓库的工作区列表
git wt list-all # 所有仓库的工作区列表Find the main repo
查找主仓库
bash
git wt origin # Print main repo path (from any worktree)bash
git wt origin # 打印主仓库路径(可在任意工作区执行)Remove worktrees
删除工作区
bash
git wt rm <name> # Remove worktree + delete its branch
git wt clean # Remove ALL worktrees for current repobash
git wt rm <name> # 删除工作区并移除对应分支
git wt clean # 删除当前仓库的所有工作区Key Details
关键细节
- Storage: — outside the repo, globally managed
~/.git-wt/<repo>/<name>/ - Branches: prefixed by default (e.g.,
wt/)wt/my-feature - Naming: auto-generates names if no name given
adjective-noun - : removes both the worktree directory and its git branch
rm - : copies all
--copy-envfiles from repo root (critical for dev servers).env* - : prints main repo path — works from any worktree or main repo itself
origin
- 存储位置:—— 位于仓库外部,全局管理
~/.git-wt/<repo>/<name>/ - 分支:默认前缀为 (例如:
wt/)wt/my-feature - 命名规则:未指定名称时自动生成“形容词-名词”格式的名称
- 命令:同时删除工作区目录及其对应的Git分支
rm - 参数:从仓库根目录复制所有
--copy-env文件(对开发服务器至关重要).env* - 命令:打印主仓库路径 —— 可在任意工作区或主仓库中执行
origin
Environment Variables
环境变量
- — Root directory for all worktrees (default:
GIT_WT_HOME)~/.git-wt - — Branch name prefix (default:
GIT_WT_PREFIX)wt
- —— 所有工作区的根目录(默认:
GIT_WT_HOME)~/.git-wt - —— 分支名称前缀(默认:
GIT_WT_PREFIX)wt
When to Use
使用场景
Use when:
git wt new- Working on a separate task that needs isolation from current work
- Running parallel agents that each need their own repo copy
- Experimenting without affecting the current branch
- Needing to quickly switch context between features
Use when:
git wt new --copy-env- The project has files needed for the dev server to start
.env - The worktree needs the same configuration as the main repo
当以下情况时使用 :
git wt new- 处理需要与当前工作隔离的独立任务
- 运行各自需要独立仓库副本的并行代理
- 在不影响当前分支的情况下进行实验
- 需要快速在不同功能分支间切换上下文
当以下情况时使用 :
git wt new --copy-env- 项目包含开发服务器启动所需的 文件
.env - 工作区需要与主仓库相同的配置
Workflow: Parallel Agent Isolation
工作流:并行代理隔离
bash
undefinedbash
undefinedAgent 1: create isolated worktree
代理1:创建独立工作区
git wt new --copy-env task-auth
git wt new --copy-env task-auth
Agent 2: create another
代理2:创建另一个工作区
git wt new --copy-env task-api
git wt new --copy-env task-api
Each agent works independently in their worktree
每个代理在各自的工作区独立工作
cd $(git wt path task-auth)
cd $(git wt path task-auth)
When done
完成后
git wt rm task-auth
git wt rm task-api
undefinedgit wt rm task-auth
git wt rm task-api
undefined