Skip to content

Merge worktree lands on the project checkout branch, not origin/main #770

Closed

Description

@currentbits

What happens

Git-tab Merge looks like it landed. The nightly / origin/main still does not have the work. Repeat for the next worktree. It feels like the #760 CI inspect refusal coming back.

What actually happens

defaultBranch() is git branch --show-current in the project checkout (electron/worktrees.js). It only falls back to origin/HEAD / main when that checkout is detached. checkoutForMerge then follows that name into whichever worktree currently holds it.

So:

#760 fixed the false CI-inspect block. After that fix, stacked merges succeed and still miss origin/main. Sign-off cannot help; the target is wrong.

#187 asked for an explicit base-branch picker and assumed merge was already hardwired to the repo default. It is not.

Fix direction

  • Git-tab Merge (no intoPath) should target the repo default (origin/HEAD → main), not whatever the project checkout happens to have checked out.
  • If that branch lives in another worktree, follow it there (existing checkoutForMerge), but refuse or warn when that main has diverged from origin/main.
  • intoPath (orchestrator → lead worktree) stays an explicit override.
  • Do not treat this as a Blast-radius guard: agent diffs touching CI/workflow files require explicit human sign-off #510 CI sign-off.

Test

Project checkout on a feature branch, worker worktree with a unique file, mergeWorktree without intoPath → file is on main, feature branch HEAD unchanged.

Activity

  1. added
    bug
    plan:todo
    plan:doing
    and removed
    plan:todo
    on Aug 29, 2026
  2. currentbits commented on Aug 29, 2026

    @currentbits
    OwnerAuthor

    Implementing on a clean origin/main branch (coder/merge-targets-origin-head-770) so this does not remelt #766 or #772.

    Approach:

    • Git-tab Merge (no intoPath) uses repoDefaultBranch (origin/HEAD → local main/master), then checkoutForMerge only stays put when that named branch is already checked out.
    • Refuse when that local default is behind origin/<default> (ahead-only is allowed).
    • intoPath still uses defaultBranch of that checkout.
    • defaultBranch() itself stays "this checkout" for setup/PR/conflict.
    • jj-detached HEAD still refuses (Jujutsu (jj) compatibility audit for worktrees and git plumbing #521).
  3. added
    plan:done
    and removed
    plan:doing
    on Aug 29, 2026
  4. currentbits commented on Aug 29, 2026

    @currentbits
    OwnerAuthor

    Landed from Solenta thread "Merge worktree lands on the project checkout branch, not ori". Closed on merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugplan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions