Fork worktrees with --no-track so new branches dont inherit the base PR#121
Merged
Conversation
…e PR
forkWorktree forks from the remote-tracking ref (origin/{base}); git's default autoSetupMerge then makes the new branch inherit that upstream. Because PR detection keys off @{u}, a branch forked from a feature branch that has an open PR showed that base branch's PR until first pushed. --no-track leaves a freshly forked branch with no upstream, so it starts with no PR and self-corrects once pushed.
Copilot-Session: 7322fc62-3803-401f-96cb-ff25c9eb917f
There was a problem hiding this comment.
Pull request overview
Prevents new worktree branches from inheriting the base branch’s upstream and incorrectly displaying its PR.
Changes:
- Adds
--no-trackto worktree creation. - Adds command-generation coverage.
- Documents the upstream and PR-detection behavior.
Show a summary per file
| File | Description |
|---|---|
src/Server/GitWorktree.fs |
Disables upstream tracking for forked branches. |
src/Tests/CreateWorktreeServerTests.fs |
Verifies --no-track is included. |
docs/spec/worktree-monitor.md |
Updates the worktree creation specification. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Medium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When Treemon creates a new worktree, it forks a new branch from a base ref with
git worktree add -b {name} {baseRef}. WhenbaseRefis a remote-tracking ref likeorigin/feature, git's defaultautoSetupMergemakes the new branch inherit the base branch's upstream (@{u}points atorigin/feature).Treemon keys PR detection off
@{u}, so the freshly forked worktree would incorrectly show the base branch's PR until the new branch was first pushed.Fix
Pass
--no-tracktogit worktree addinresolveWorktreeCommand(src/Server/GitWorktree.fs). This disablesautoSetupMergefor the fork, so the new branch starts with no upstream — which is correct, since a freshly forked branch has no remote of its own yet. PR detection then reports nothing for the new worktree until it is actually pushed.Changes
src/Server/GitWorktree.fs— add--no-trackto theworktree addcommand; document why onresolveWorktreeCommand.src/Tests/CreateWorktreeServerTests.fs— new test asserting the fork command contains--no-track.docs/spec/worktree-monitor.md— update the fork spec to reflect--no-trackand the PR-detection rationale.Tests
forks with --no-track so the new branch does not inherit the base upstreamtoResolveWorktreeCommandTests.