git-worktree
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit Worktree Manager
Git Worktree 管理器
Manage repositories using git worktrees. This allows working on multiple branches simultaneously without switching or stashing.
使用Git worktree管理仓库。这允许你同时处理多个分支,无需切换分支或暂存更改。
Concept
概念
~/dev/personal/auto/
├── my-project/ # Main clone (bare or with default branch)
│ └── .git/
└── my-project-worktrees/ # Worktrees directory
├── feature-123/ # Worktree for feature branch
├── feature-456/ # Another feature branch
└── hotfix-789/ # Hotfix branch~/dev/personal/auto/
├── my-project/ # 主克隆仓库(裸仓库或带有默认分支)
│ └── .git/
└── my-project-worktrees/ # Worktree 目录
├── feature-123/ # 功能分支对应的Worktree
├── feature-456/ # 另一个功能分支
└── hotfix-789/ # 热修复分支Quick Reference
快速参考
| Action | Script |
|---|---|
| Clone repo | |
| Create worktree | |
| List worktrees | |
| Remove worktree | |
| 操作 | 脚本 |
|---|---|
| 克隆仓库 | |
| 创建Worktree | |
| 列出Worktree | |
| 删除Worktree | |
Workflow Examples
工作流示例
Start working on a JIRA ticket
开始处理JIRA工单
bash
undefinedbash
undefinedClone if not already done
若未克隆则执行克隆
./scripts/clone_repo.sh https://github.com/org/my-app.git
./scripts/clone_repo.sh https://github.com/org/my-app.git
Create worktree for ticket
为工单创建Worktree
./scripts/create_worktree.sh my-app PROJ-123-new-feature
./scripts/create_worktree.sh my-app PROJ-123-new-feature
Work in the worktree directory
进入Worktree目录开展工作
cd ~/dev/personal/auto/my-app-worktrees/PROJ-123-new-feature
undefinedcd ~/dev/personal/auto/my-app-worktrees/PROJ-123-new-feature
undefinedClean up after PR merged
PR合并后清理
bash
./scripts/remove_worktree.sh my-app PROJ-123-new-featurebash
./scripts/remove_worktree.sh my-app PROJ-123-new-featureIntegration
集成
Uses to determine the work directory. Repositories are cloned to and worktrees are created in .
workspace-manager<workspace_path>/<repo_name>/<workspace_path>/<repo_name>-worktrees/使用确定工作目录。仓库会被克隆到,Worktree则创建在目录下。
workspace-manager<workspace_path>/<repo_name>/<workspace_path>/<repo_name>-worktrees/