ndrone
ndrone

Reputation: 3582

How do I delete old remote refs that are no longer valid

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?

Upvotes: 4

Views: 3793

Answers (1)

torek
torek

Reputation: 488183

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".

Upvotes: 4

Related Questions