Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


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
Community Members
Community Events
Community Groups

How to remove refs on remote git repo


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


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?


Hey @Fabio Pires , @CPJ , have any of you found a solution to this?

Well, I basically renamed the repo to something like "reponame-old", created a new repo with the same name, and did something along the lines of:

  • git clone --quiet --bare ssh://git@.../reponame-old
  • cd reponame-old
  • git push --quiet --mirror ssh://git@.../newrepo.git

Thanks, what worked for us was that we selectively pushed the references - that is, skip pushing the problematic references while pushing everything else. 

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events