fix(worktree): base new worktrees on origin/<branch> by default#37
Merged
fix(worktree): base new worktrees on origin/<branch> by default#37
Conversation
Follow-up to #35. The pre-create fetch was gated on `branchType !== "local"`, but the new-chat UI auto-selected the local variant of the default branch whenever both local and remote existed — so in the common case (local `main` tracking `origin/main`) the fetch never ran and worktrees inherited whatever stale state the user had locally. - Auto-select prefers the remote variant of the default branch, so the worktree starts from a fresh `origin/<branch>`. - `git fetch origin <baseBranch>` now runs whenever origin exists, regardless of branch type. Failures remain best-effort. User's local branch is left untouched. Explicit local branch selection is still honored. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
origin/<branch>instead of a potentially stale local ref.branchType !== "local"gate on the pre-create fetch, sogit fetch origin <baseBranch>runs whenever anoriginremote is configured.Why
#35 added a pre-create fetch, but gated it on
branchType !== "local". The new-chat UI preferred the local variant of the default branch when both existed (the common case: localmaintrackingorigin/main), sobranchTypewas always"local"and the fetch never ran. Worktrees inherited whatever stale state the user happened to have locally — the original bug this series was supposed to fix.User's local branch is left untouched (no fast-forward). Explicit branch selection from the dropdown is still honored.
Test plan
mainbehindorigin/main: new workspace → worktree HEAD includes commits only onorigin/mainoriginremote: worktree creation still succeeds