Skip to content

gh operations that delete the remote branch leave a dangling reference in the local git repo #8515

Description

@asakatida

Describe the bug

any operation like gh pr merge -d that deletes a remote branch leaves a reference locally to the remote branch. This can be seen by doing git fetch --prune after and observing a line starting with - [deleted] (none) -> or by any of the operations from git that will show remote references. They will all show the remote branch as still existing an allow referencing it in any local git command before the git fetch --prune.

gh version 2.40.1 (2023-12-13)
https://github.com/cli/cli/releases/tag/v2.40.1

Steps to reproduce the behavior

  1. Type this gh pr merge -d then git fetch --prune
  2. View the output ' - [deleted] (none) -> '
  3. See error

Expected vs actual behavior

Expected behavior is that git fetch --prune shows no changes

Logs

> gh pr merge -d -r 2853
✓ Rebased and merged pull request #2853 (Update fuzzing corpus.)
✓ Deleted local branch corpus-7284481772-merge
✓ Deleted remote branch corpus-7284481772-merge
> git fetch --all --prune --prune-tags --tags
From github.com:asakatida/chimera
 - [deleted]               (none)     -> origin/corpus-7284481772-merge

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIgh-prrelating to the gh pr command

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions