Skip to content

feat: add wt.symlink config and --symlink flag#164

Merged
k1LoW merged 1 commit intok1LoW:mainfrom
ryoppippi:feat/symlink-copy
Mar 28, 2026
Merged

feat: add wt.symlink config and --symlink flag#164
k1LoW merged 1 commit intok1LoW:mainfrom
ryoppippi:feat/symlink-copy

Conversation

@ryoppippi
Copy link
Copy Markdown
Contributor

Summary

  • Add wt.symlink git config and --symlink CLI flag for symlinking directories instead of copying
  • Matching top-level directories (gitignore syntax) are symlinked to the source worktree
  • Non-matching directories and root-level files are still copied normally
  • Symlinks are created before file-by-file copy, and files inside symlinked directories are skipped

Use case

Large directories like node_modules (5.9GB+, 265K+ files) take ~21s even with clonefile. Symlinking is instantaneous:

git config --add wt.symlink "node_modules/"

Trade-off: symlinked directories are shared — npm install in one worktree affects all others. Use this when the directory is read-only or rebuilt by hooks.

Test plan

  • TestCopyFilesToWorktree_Symlink — verifies symlink is created, target is correct, files accessible through symlink, non-symlink files copied normally
  • TestCopyFilesToWorktree_Symlink_NonMatchingDir — verifies only matching directories are symlinked, others are copied
  • All existing copy tests pass
  • Full e2e test suite passes

Add support for symlinking directories instead of copying when creating
new worktrees. This is useful for large directories like node_modules
where sharing the same files across worktrees is acceptable and much
faster than copying.

Symlink patterns use gitignore syntax and match top-level directories.
Matching directories are symlinked to the source worktree, so changes
in the source are immediately visible in all worktrees that symlink it.

Usage:
  git config --add wt.symlink "node_modules/"
  git wt my-branch --symlink "node_modules/"

Non-matching directories are still copied normally. Files at the root
level are never symlinked, only directories.
@k1LoW k1LoW added enhancement New feature or request tagpr:minor labels Mar 28, 2026
@k1LoW
Copy link
Copy Markdown
Owner

k1LoW commented Mar 28, 2026

@ryoppippi GREAT!! Thank you!!

@k1LoW k1LoW merged commit ec04aca into k1LoW:main Mar 28, 2026
3 checks passed
@github-actions github-actions Bot mentioned this pull request Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tagpr:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants