Repository navigation
Create worktrees in repositories that have no origin - #524
Merged
powerfooI merged 2 commits intoOct 31, 2026
Merged
Conversation
Creating a worktree first refreshes the repository's origin default branch to pick the base commit. A local repository with no origin remote failed there, so no worktree could be created from it at all. When git reports that origin is missing, and the repository really has no origin remote, branch from the commit that is checked out instead; any other fetch failure still surfaces.
Git translates its messages, so the English text of the missing-origin error is not there on a machine set to French, say. Git quotes the remote's name in every language, so look for 'origin' and let the remote lookup decide; a repository that has an origin still reports its fetch failure.
Owner
|
Reviewed and merged. Re-ran |
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.
Creating a worktree first refreshes the repository's
origindefault branch to pick the base commit. A local repository with nooriginremote failed there, so no worktree could be created from it at all.When the refresh fails with an error naming
'origin'(git quotes the remote's name in every language it speaks, so this works with a translated git too), andgit remote get-url originconfirms the repository has nooriginremote, the new worktree now branches from the commit that is checked out (HEAD). Any other failure, including an unreachable or misconfiguredorigin, still surfaces as before.Changes
server/src/worktree/create.ts:syncWorktreeBasefalls back toHEAD^{commit}for repositories without anoriginremote.server/src/workspace/default-branch.test.ts: real-git test that a repository withoutorigingetsbase: "HEAD"and the checked-out commit.server/src/worktree/create.test.ts: the same with git answering in French; it fails without the change.Verification
bun test server/src/worktree/create.test.ts server/src/workspace/default-branch.test.ts: 55 pass, 0 fail. The existing "does not fall back to another base when ..." cases still pass, so failures with anoriginare not masked.bun run format:checkon the changed files: clean.bun run lint: clean apart from the existingTerminalView.tsxexhaustive-deps warning.bun run typecheck: passes, including the web build and asset budget check (initial JS 805.0/805 KiB).bun run test:quickwith an isolatedHOME, onmainplus this change and the other small fixes I am sending alongside: 3965 pass, 4 skip, 2 fail. Both failures (useMobileControlsDrag.keyboard.test.tsand the SSH paths test) fail the same way onmainon macOS.Manual check, not repeated on this branch:
origin, create a worktree from the workspace menu: it is created from the current commit.Compatibility
No API or settings changes.