Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
asakatida opened this issue Jan 2, 2024 · 4 comments
Labels
enhancement a request to improve CLI gh-pr relating to the gh pr command needs-triage needs to be reviewed

Comments

@asakatida
Copy link

asakatida commented Jan 2, 2024

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
@asakatida asakatida added the bug Something isn't working label Jan 2, 2024
@cliAutomation cliAutomation added the needs-triage needs to be reviewed label Jan 2, 2024
@andyfeller andyfeller added enhancement a request to improve CLI gh-pr relating to the gh pr command and removed bug Something isn't working labels Jan 5, 2024
@samcoe
Copy link
Contributor

samcoe commented Jan 10, 2024

@asakatida Thanks for the feature request. I see that there is already a PR open to address this. I have one question though, what is the reason for wanting to remove these references? Is having them around detrimental to your workflow in anyway?

@samcoe samcoe added needs-user-input and removed needs-triage needs to be reviewed labels Jan 10, 2024
@asakatida
Copy link
Author

I query these references frequently with git branch -r. This bug means that they are out of date despite the claim in gh output that the remote branch has been deleted.

@williammartin williammartin added needs-triage needs to be reviewed and removed needs-user-input labels Jan 16, 2024
@samcoe
Copy link
Contributor

samcoe commented Jan 16, 2024

What is the reasons for querying the remote references? What are you trying to achieve doing that?

I think there is a bit of a misunderstanding here about the --delete-branch flag. The flag will delete the local git branch and the branch on the remote server, which is GitHub. We do use the term "remote branch" in gh pr merge --help which I think is confusing because git has the concept of a remote branch but that is not what we are deleting, those remote references are being left in place. I am not opposed to trying to clean up those references if we have a good reason to introduce that functionality.

@asakatida
Copy link
Author

I query the remote references so I can script operations on the git repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement a request to improve CLI gh-pr relating to the gh pr command needs-triage needs to be reviewed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants