Git Mirroring created unwanted PR refs on target repository

507 Views Asked by At

I have a periodic git synchronization script that runs from bit bucket cloud to our local git repository.

In the nutshell it does the following:

git clone --mirror ssh://source.git
git show-ref | cut -d ' ' -f2 | grep 'pull-request' | xargs -r -L1 git update-ref -d
git push --mirror ssh://target.git

This sequence cloned the source repo, cleaned all pull request references and pushed to target repository. It was working without issues for a few months, but today I got the following error:

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/1/from

remote: refs/pull-requests/1/merge remote: ! [remote

rejected] refs/pull-requests/1/from (pre-receive hook declined) !

[remote rejected] refs/pull-requests/1/merge (pre-receive hook

declined

)

On the target repository, I can see these weird references, but no pull requests in the UI. I am suspected something became corrupted on the target repository, but I was unable to clear these references with

git update-ref -d refs/pull-requests/1/merge
git update-ref -d refs/pull-requests/1/from
git push

That operation produces the following error:

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/1/from remote:

refs/pull-requests/1/merge

I have 2 questions :)

1) What can cause this kind of corruption in the target repository?

2) Is there any way to get rid of these references on the target?

0

There are 0 best solutions below