worktree-deps-autolink
v0.1.1
Published
Auto-link untracked top-level files from the main Git worktree into newly added worktrees.
Readme
worktree-deps-autolink
安装后自动注入 Git hook:当执行 git worktree add 创建新 worktree 时,自动运行 link-untracked.cjs,把主 worktree 顶层未跟踪文件/目录软链接到新 worktree。
使用
npm install -D worktree-deps-autolink安装脚本会在当前仓库设置:
git config core.hooksPath <main-repo>/.git/worktree-deps-autolink/_也可以手动执行:
npx worktree-deps-autolink
npx worktree-deps-autolink link
npx worktree-deps-autolink install
npx worktree-deps-autolink status
npx worktree-deps-autolink uninstall不带参数或使用 link 会立即在当前目录运行链接逻辑,适合在已有 worktree 中手动补链。
触发条件
注入的是 post-checkout hook,仅在以下条件都满足时执行链接脚本:
post-checkout的第三个参数为1- 第一个参数是全零 revision,即新 worktree 的首次 checkout
- 未设置
WORKTREE_DEPS_AUTOLINK=0
跳过安装或执行
WORKTREE_DEPS_AUTOLINK=0 npm install
WORKTREE_DEPS_AUTOLINK=0 git worktree add ../foo如果安装前已经配置过 core.hooksPath,生成的 hook 会在执行完自动链接逻辑后继续调用原 post-checkout hook。
