You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With branch.autoSetupMerge=simple, creating a branch whose name differs from its remote base leaves the new branch without an upstream, as documented by Git.
Worktrunk then unconditionally runs git branch --unset-upstream for a remote-tracking base. Git reports that there is no upstream to unset, and Worktrunk exits 1.
By that point, the branch and worktree have already been created successfully. With --format=json, stdout is empty, so automation receives a failure and no result even though the requested worktree exists.
The reproduction below isolates both Git and Worktrunk from user configuration. It uses only repository-local Git configuration and a local bare remote.
emit the normal {"action":"created", ...} JSON result; and
exit 0.
An absent upstream already satisfies the safety requirement. It should therefore be treated as success rather than as an error from the overall operation.
Cause and effect
Git documents branch.autoSetupMerge=simple as setting up tracking only when:
the start point is a remote-tracking branch; and
the new branch has the same name as the remote branch.
At the time of this report, source inspection of main at e5f9589c showed the same unconditional call.
Control
A fresh clone with branch.autoSetupMerge=true does not fail:
$ git config --local branch.autoSetupMerge true
# exit 0
$ wt switch --create oscar/recover-worktrunk --base origin/main --no-cd --format=json{"action":"created","branch":"oscar/recover-worktrunk","path":"/tmp/worktrunk-v075-repro.mD6nA3/control-true.oscar-recover-worktrunk","created_branch":true,"base_branch":"origin/main"}✓ Created branch oscar/recover-worktrunk from origin/main and worktree @ /tmp/worktrunk-v075-repro.mD6nA3/control-true.oscar-recover-worktrunk↳ To customize worktree locations, run wt config create
# exit 0
$ git for-each-ref \ '--format=%(refname:short) upstream=%(upstream:short)' \ refs/heads/oscar/recover-worktrunkoscar/recover-worktrunk upstream=
# exit 0
With true, Git creates the tracking relationship for a remote-tracking start point, so Worktrunk has an upstream to remove. The final safe state is otherwise the same.
Verified workarounds
Recover after the failure
The failed invocation has already created the worktree. Switch to the existing branch without --create:
$ wt switch oscar/recover-worktrunk --no-cd --format=json{"action":"existing","branch":"oscar/recover-worktrunk","path":"/tmp/worktrunk-v075-repro.mD6nA3/failure.oscar-recover-worktrunk"}○ Switched to worktree for oscar/recover-worktrunk @ /tmp/worktrunk-v075-repro.mD6nA3/failure.oscar-recover-worktrunk
# exit 0
Resolve the remote-tracking base to its commit first
This preserves the current origin/main commit while avoiding the remote-base cleanup path:
$ base=$(git rev-parse origin/main)
$ wt switch --create oscar/recover-sha \ --base "$base" \ --no-cd \ --format=json{"action":"created","branch":"oscar/recover-sha","path":"/tmp/worktrunk-v075-repro.mD6nA3/workaround-sha.oscar-recover-sha","created_branch":true,"base_branch":"1e80abd0b884ad69ed02fea298772235669be5bb"}✓ Created branch oscar/recover-sha from 1e80abd0b884ad69ed02fea298772235669be5bb and worktree @ /tmp/worktrunk-v075-repro.mD6nA3/workaround-sha.oscar-recover-sha↳ To customize worktree locations, run wt config create
# exit 0
$ git for-each-ref \ '--format=%(refname:short) upstream=%(upstream:short)' \ refs/heads/oscar/recover-shaoscar/recover-sha upstream=
# exit 0
The created branch SHA was also verified to equal the resolved origin/main SHA.
Not verified
I did not run the reproduction on operating systems or Git versions other than Linux x86_64 with Git 2.55.0.
I did not build and run the current main branch; the statement about main above is source inspection only.
I did not bisect Worktrunk releases to identify the first released version containing this failure.
Other branch.autoSetupMerge values that can omit tracking, such as false, were not tested.
This report was generated by an AI coding agent. The reproduction and outputs were verified locally before posting.
Summary
With
branch.autoSetupMerge=simple, creating a branch whose name differs from its remote base leaves the new branch without an upstream, as documented by Git.Worktrunk then unconditionally runs
git branch --unset-upstreamfor a remote-tracking base. Git reports that there is no upstream to unset, and Worktrunk exits 1.By that point, the branch and worktree have already been created successfully. With
--format=json, stdout is empty, so automation receives a failure and no result even though the requested worktree exists.Environment
The reproduction below isolates both Git and Worktrunk from user configuration. It uses only repository-local Git configuration and a local bare remote.
Minimal deterministic reproduction
Actual result
Captured output from the failing command:
Despite that failure, the same run showed that the branch and linked worktree exist:
Running the failing Git operation directly confirms its exit status:
The temporary repository shown above was removed after verification.
Expected result
The command should:
{"action":"created", ...}JSON result; andAn absent upstream already satisfies the safety requirement. It should therefore be treated as success rather than as an error from the overall operation.
Cause and effect
Git documents
branch.autoSetupMerge=simpleas setting up tracking only when:See
git-branchdocumentation.Here the names differ:
The resulting sequence is:
oscar/recover-worktrunkfromorigin/main.branch.autoSetupMerge=simpleapplies, Git does not configure an upstream.origin/mainas a remote-tracking base and callsunset_upstream()unconditionally.git branch --unset-upstreamexits 128 because there is nothing to unset.The relevant v0.75.0 code is:
switch.rsunset_upstream()propagating the Git command failureThis safety path originated in #713 and PR #717.
At the time of this report, source inspection of
mainate5f9589cshowed the same unconditional call.Control
A fresh clone with
branch.autoSetupMerge=truedoes not fail:With
true, Git creates the tracking relationship for a remote-tracking start point, so Worktrunk has an upstream to remove. The final safe state is otherwise the same.Verified workarounds
Recover after the failure
The failed invocation has already created the worktree. Switch to the existing branch without
--create:Resolve the remote-tracking base to its commit first
This preserves the current
origin/maincommit while avoiding the remote-base cleanup path:The created branch SHA was also verified to equal the resolved
origin/mainSHA.Not verified
mainbranch; the statement aboutmainabove is source inspection only.branch.autoSetupMergevalues that can omit tracking, such asfalse, were not tested.