Skip to content

feat(code): add .worktreeinclude support#1344

Open
adboio wants to merge 1 commit intomainfrom
03-27-feat_code_add_.worktreeinclude_support
Open

feat(code): add .worktreeinclude support#1344
adboio wants to merge 1 commit intomainfrom
03-27-feat_code_add_.worktreeinclude_support

Conversation

@adboio
Copy link
Copy Markdown
Contributor

@adboio adboio commented Mar 27, 2026

Problem

tragically, i think we really should make worktrees work well

Changes

less tragically, i think this small change makes it all better :)

  • added support for .worktreeinclude and .worktreelink files
  • they do what they sound like; include copies files and link symlinks files
  • both are filtered to only include files that are gitignored, which matches cc's implementation

How did you test this?

added these tiny pieces to the main repo, and it all works pretty smoothly: https://app.graphite.com/github/pr/PostHog/posthog/52566

Copy link
Copy Markdown
Contributor Author

adboio commented Mar 27, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@adboio adboio force-pushed the 03-27-feat_code_add_.worktreeinclude_support branch from c167eab to 0ad0219 Compare March 27, 2026 14:11
Copy link
Copy Markdown
Contributor

@jonathanlab jonathanlab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, lgtm! wonder if we could do with some docs about this as well

this.git.raw(["worktree", "add", "-b", branchName, worktreePath, base]),
this.git.raw([
"-c",
"core.hooksPath=/dev/null",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I assume this is to circumvent the husky hooks in the posthog/posthog repository right? Do we want to make it configurable if these hooks are enabled/disabled? Totally up to you

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but not to circumvent, just to delay

we still run these later -- we just skip them here so the worktreeinclude and worktreelink processes can complete first, as the hooks may depend on them (ours do)

Copy link
Copy Markdown
Contributor

Also would be awesome if we could let users config this in the Worktree settings page, but thats for another PR :D

Copy link
Copy Markdown
Contributor Author

adboio commented Mar 28, 2026

@jonathanlab agree! if this works out, i'll take another pass to imrpove the UX a bit:

  • add config stuff as you suggest
  • probably improve on the loading states / transitions
  • maybe have the post-checkout hooks run in parallel with the session init just as a wall-clock time saver

@adboio adboio marked this pull request as ready for review March 28, 2026 01:54
@adboio adboio requested a review from jonathanlab March 28, 2026 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants