4

I have a few old pull requests that are no longer valid, but their refs are still hanging around.

git ls-remote enter image description here

how do I go about removing these old refs on the remote?

ndrone
  • 3,524
  • 2
  • 23
  • 37
  • Possible duplicate of [How do you remove an invalid remote branch reference from Git?](https://stackoverflow.com/questions/1072171/how-do-you-remove-an-invalid-remote-branch-reference-from-git) – Inigo Feb 02 '18 at 16:13

1 Answers1

4

You could, on the server itself, use git update-ref to delete these references. That method is more or less guaranteed to work—but requires that you be able to log in on the server itself.

The in-Git alternative, which may or may not be allowed by the server, is to send the server a push request of the form "delete ", using, e.g.:

git push --delete origin refs/pull-requests/70/from refs/pull-requests/70/merge

or equivalently:

git push origin :refs/pull-requests/70/from :refs/pull-requests/70/merge

The server might reject this request, saying that references in the refs/pull-requests namespace are reserved. If that's true, you're stuck with either:

  • log in on the server and use a Git command there, or
  • bypass Git entirely, perhaps by using a web interface.

It seems likely that the web interface (or similar) is the raison d'être for the use of that particular server in the first place: through their web interface, they provide features like "fork repository" and "make pull request".

torek
  • 448,244
  • 59
  • 642
  • 775
  • That looks like it would work if I had the correct access from the server itself to do this. But I am currently being blocked the product because it is managed internally by the product itself. Here is the message returned from the server for reference: `remote: You are attempting to update refs that are reserved for Bitbucket's pull request functionality. Bitbucket manages these refs automatically, and they may not be updated by users.` – ndrone Jan 10 '18 at 17:54
  • "The server might *reject* this request ... if that's true, (bullet points)". I note you never mentioned bitbucket specifically in the question (nor in tags). – torek Jan 10 '18 at 17:57