twig-guide

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

twig CLI Guide

twig CLI 指南

twig is a CLI tool that simplifies git worktree workflows by automating branch creation, symlinks, and change management in a single command.
twig是一款CLI工具,通过单条命令自动化分支创建、符号链接和变更管理,简化git worktree工作流。

Commands Overview

命令概述

CommandPurpose
twig init
Initialize twig configuration
twig add <name>
Create a new worktree with symlinks
twig remove <branch>...
Remove worktrees and their branches
twig list
List all worktrees
twig clean
Remove unneeded worktrees
twig sync
Sync symlinks and submodules to worktrees
命令用途
twig init
初始化twig配置
twig add <name>
创建带有符号链接的新工作树
twig remove <branch>...
删除工作树及其分支
twig list
列出所有工作树
twig clean
删除不需要的工作树
twig sync
将符号链接和子模块同步到工作树

Typical Workflows

典型工作流

Start new feature work

开始新功能开发

Create a new worktree for a feature branch:
bash
twig add feat/new-feature
This creates a worktree at the configured destination directory, creates a new branch if it doesn't exist, and sets up symlinks.
为功能分支创建新工作树:
bash
twig add feat/new-feature
此命令会在配置的目标目录创建工作树,如果分支不存在则创建新分支,并设置符号链接。

Move current changes to a new branch

将当前更改转移到新分支

When you realize current work should be on a different branch:
bash
twig add feat/correct-branch --carry
The
--carry
flag moves uncommitted changes to the new worktree. The source worktree becomes clean.
当你意识到当前工作应该放在另一个分支时:
bash
twig add feat/correct-branch --carry
--carry
标志会将未提交的更改转移到新工作树,源工作树会变为干净状态。

Copy changes to a new branch

将更改复制到新分支

When you want changes in both the current and new worktree:
bash
twig add feat/experiment --sync
The
--sync
flag copies uncommitted changes to both worktrees.
当你希望当前工作树和新工作树都保留更改时:
bash
twig add feat/experiment --sync
--sync
标志会将未提交的更改复制到两个工作树中。

Carry only specific files

仅转移特定文件

When you want to carry only certain files:
bash
twig add feat/new --carry --file "*.go" --file "cmd/**"
当你只想转移某些文件时:
bash
twig add feat/new --carry --file "*.go" --file "cmd/**"

Clean up after merging

合并后清理

Remove worktrees for branches that have been merged:
bash
twig clean
This shows candidates and prompts for confirmation. Use
--yes
to skip the prompt.
删除已合并分支对应的工作树:
bash
twig clean
此命令会显示候选清理项并提示确认,使用
--yes
可跳过提示。

Force remove a worktree

强制删除工作树

Remove a worktree even with uncommitted changes:
bash
twig remove feat/abandoned -f
Use
-ff
to also remove locked worktrees.
即使存在未提交的更改,也删除工作树:
bash
twig remove feat/abandoned -f
使用
-ff
还可删除锁定的工作树。

Configuration

配置

see ./references/configuration.md
请查看 ./references/configuration.md

Command Details

命令详情

For detailed information on each command, refer to:
  • ./references/commands/add.md - Create worktrees with sync/carry options
  • ./references/commands/remove.md - Remove worktrees and branches
  • ./references/commands/list.md - List worktrees
  • ./references/commands/clean.md - Clean merged worktrees
  • ./references/commands/sync.md - Sync symlinks and submodules
  • ./references/commands/init.md - Initialize configuration
  • ./references/configuration.md - Configuration file details
如需各命令的详细信息,请参考:
  • ./references/commands/add.md - 带有同步/转移选项的工作树创建
  • ./references/commands/remove.md - 删除工作树和分支
  • ./references/commands/list.md - 列出工作树
  • ./references/commands/clean.md - 清理已合并的工作树
  • ./references/commands/sync.md - 同步符号链接和子模块
  • ./references/commands/init.md - 初始化配置
  • ./references/configuration.md - 配置文件详情