Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,682
Community Members
 
Community Events
165
Community Groups

How to remove refs on remote git repo

Edited

We have a git repo on bitbucket server that has some refs we need to delete.
I can view the remote refs by calling:

git ls-remote --refs | grep pull-requests

Giving:

634746a29a3a077254960538a3fbc421a174d68b refs/pull-requests/426/merge
fe80ad1e8d34fab4bb599595c9c584bdbca33125 refs/pull-requests/450/from
...
764a8d6d4d307c7a1b57bcde76ef9fde140f3562 refs/pull-requests/614/from
1fba4de34e609d3dc33c092d39af0d4ad13030e1 refs/pull-requests/614/merge

These pull requests don't actually exist in bitbucket (i.e. Don't show up as real pull requests). The numbers for the pull requests mark them as being really old too, years old. So we need to delete them. So when I try removing one of those dangling refs, for instance:

git push --delete origin refs/pull-requests/364/from

Bitbucket returns an error message stating:

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. remote: Rejected
refs: remote: refs/pull-requests/364/from remote:

First question: Why is Bitbucket being so damned fussy on this issue? It's my git repo, I want those deleted.

Second question: Am I calling the correct command to remove the remote ref? 

1 answer

Hey @CPJ , sorry for reviving this 3yo topic, but: have you found a solution?

Cheers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,110 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you