Skip to content

Fork worktrees with --no-track so new branches dont inherit the base PR#121

Merged
0101 merged 2 commits into
mainfrom
pr-detection-no-track
Jul 17, 2026
Merged

Fork worktrees with --no-track so new branches dont inherit the base PR#121
0101 merged 2 commits into
mainfrom
pr-detection-no-track

Conversation

@0101

@0101 0101 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Problem

When Treemon creates a new worktree, it forks a new branch from a base ref with git worktree add -b {name} {baseRef}. When baseRef is a remote-tracking ref like origin/feature, git's default autoSetupMerge makes the new branch inherit the base branch's upstream (@{u} points at origin/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-track to git worktree add in resolveWorktreeCommand (src/Server/GitWorktree.fs). This disables autoSetupMerge for 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-track to the worktree add command; document why on resolveWorktreeCommand.
  • 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-track and the PR-detection rationale.

Tests

  • Added forks with --no-track so the new branch does not inherit the base upstream to ResolveWorktreeCommandTests.

0101 added 2 commits July 17, 2026 14:10
…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
Copilot AI review requested due to automatic review settings July 17, 2026 13:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Prevents new worktree branches from inheriting the base branch’s upstream and incorrectly displaying its PR.

Changes:

  • Adds --no-track to 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

@0101
0101 merged commit 5e66290 into main Jul 17, 2026
2 checks passed
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