Worktree
一句话解释
worktree 是 additional 工作 directory 链接到 相同仓库, letting 你工作 on 多个分支 simultaneously 不使用 cloning.
用大白话说
git worktree lets you have multiple working directories for the same repository, each checked out to a different branch. This avoids the need to stash, clone, or switch branches when you need to work on two things at once.
For example, you can have your main worktree on the feature branch and a second worktree on 主要 to fix a quick bug, without disturbing your feature work. Both worktrees share the same .git storage, so commits made in one are visible in the other.
Worktrees are useful for long-running tasks (tests, builds) on one branch while you work on another, or for keeping a stable checkout for reference while developing in another. Clean up with git worktree 移除 when done.
示例
# Add a worktree on the main branch
git worktree add ../project-main main
# Now you have two working directories:
# ./project (on feature)
# ../project-main (on main)
# List worktrees
git worktree list
# Remove a worktree
git worktree remove ../project-mainworktree 创建 additional 工作 directories for 相同仓库.
相关术语
相关资源
相关课程
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。