Skip to content

gh issue develop --name <existing-branch> fails with "API returned empty branch name" instead of saying the branch already exists #14946

Open

Description

@ronin9110

Describe the bug

When --name is a branch that already exists on the remote, gh issue develop fails with:

failed to create linked branch: API returned empty branch name

The message points at the API response, not the cause. The underlying createLinkedBranch mutation returns HTTP 200 with {"data":{"createLinkedBranch":{"linkedBranch":null}}} and no errors, and nothing is linked or created.

This is likely the real cause behind #13805, which was closed without a reproduction: that report blamed the slash in the branch name, but the test below shows an existing branch fails with or without a slash, and a new branch with a slash works.

Affected version

gh version 2.92.0 (2026-04-28), Linux

Steps to reproduce the behavior

  1. In any repository, push two branches: example and feat/example.
  2. Open an issue.
  3. Run gh issue develop <issue> --repo <owner>/<repo> --name example --base example.
  4. See failed to create linked branch: API returned empty branch name. gh issue develop --list <issue> shows nothing linked.
  5. Repeat with --name feat/example --base feat/example: same error.
  6. Run gh issue develop <issue> --repo <owner>/<repo> --name feat/new-example --base main: the branch is created and linked.

Tested

Private repository, gh 2.92.0, every branch pointing at the same main commit:

Branch passed to --name Already on remote? Result
example yes API returned empty branch name, exit 1, nothing linked
feat/example yes API returned empty branch name, exit 1, nothing linked
feat/new-example no branch created and linked (--list shows it)

Request ID of a failing mutation (from GH_DEBUG=api): DB0E:26CBEE:1EB28F1:2CA6176:6AEC648D

The third run was made outside a git checkout, so it also exited 1 with fatal: not in a git directory after creating the branch; that is #14856.

Expected vs actual behavior

Expected: before calling createLinkedBranch, check whether the branch already exists and say so, for example "branch example already exists; the API can only link a new branch. Link it from the issue's Development sidebar." Or check for a null linkedBranch and explain it.

Actual: a generic "empty branch name" error.

Additional context

The API side (no way to link an existing branch, and the silent null) is reported in https://github.com/orgs/community/discussions/212130.

Activity

  1. added
    needs-triage
    on Nov 5, 2026
  2. cli-triage commented on Nov 9, 2026

    @cli-triage

    Partly reproduced on 2.92.0.

    Using test data for the reported null mutation response:

    $ gh issue develop 1 -R example.invalid/hello --name example --base example
    failed to create linked branch: API returned empty branch name

    Exit status: 1.

    The same command produced the same result on 2.103.3 and the selected source build. This confirms the CLI handles a null linked branch with the generic empty-name error. The test did not verify that an already-existing remote branch causes GitHub to return null. Using a new branch name remains the command-line workaround.

    Supporting reports

    Generated by issue triage.

  3. deleted a comment from cli-triage on Nov 9, 2026
  4. added
    bug
    gh-issue
    priority-3
    on Nov 9, 2026
  5. removed
    needs-triage
    on Nov 9, 2026
  6. ronin9110 commented on Nov 11, 2026

    @ronin9110
    Author

    To cover the server side the triage run couldn't check: calling the mutation directly against github.com, with the name and head oid of a branch that already exists, returns HTTP 200 and

    {"data":{"createLinkedBranch":{"linkedBranch":null}}}

    with no errors (request ID AB38:13AF3E:16BC662:2169649:6AEC3B6A). The same call with a new branch name creates and links the branch. So an existing branch name is what produces the null.

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

    buggh-issuepriority-3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions