Skip to content

Gracefully handle when branches automatically deleted when PR is merged #1010

@janko

Description

@janko

Describe the feature or problem you’d like to solve

In our repo we have configured that branches are automatically deleted when a pull request is merged. The new gh pr merge command works great, but it produces a warning:

failed to delete remote branch <my-branch>: http error, 'https://api.github.com/repos/<my-organization>/<my-repo>/git/refs/heads/my-branch failed (422): 'Reference does not exist'

I assume it's because it tried to delete the remote branch, but couldn't find it because GitHub had already deleted it.

Proposed solution

It would be nice if the warning wasn't displayed in this case, so that it doesn't look like anything is wrong.

Additional context

Just in case, I've executed the following commands:

$ gh pr create
$ gh pr merge --squash

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions