在 repo-cleaning 中拒绝引用

Rejected refs in repo-cleaning

我正在清理 git 存储库的拉取请求 (PR)。有一个 PR 创建用于合并分支 B,后来在合并之前被认为已弃用和删除。结果,分支 B 被删除,并且这个 PR 没有出现在 Bitbucket 的拉取请求列表中。但是,如果我使用 git show-ref,则此 PR 会出现在参考列表以及远程存储库历史记录中。有没有办法在远程仓库中清除这个 PR?

master branch
|
|
|   * branch B, Pull Request
|   |
|   /
|  /
| /
|/
*
|
|

增加: 这个 PR 存在于远程仓库中。我可以制作一个裸副本到本地并使用 git reflog expire --expire=now --all && git gc --prune=now --aggressive 删除本地 PR,但不知道如何删除远程存储库中的这个 PR。

我在使用 BFG 清理存储库历史记录时遇到了这个问题 here. My push of local changes to remote was rejected due to rejected refs (as shown below, and here is a related discussion on this topic)

(base) ****@*****:~/*****/abcde.git$ git push --force
Username for *****************:
Password for *****************:
Counting objects: 17811, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (10604/10604), done.
Writing objects: 100% (17811/17811), 367.27 MiB | 2.16 MiB/s, done.
Total 17811 (delta 6545), reused 17811 (delta 6545)
remote: Resolving deltas: 100% (6545/6545), done.
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/2/from
remote:         refs/pull-requests/2/merge
remote:         refs/pull-requests/5/from
remote:         refs/pull-requests/5/merge
remote:

更新:

最后,我通过创建一个新的空远程存储库并将我的本地 git 镜像推送到那里来绕过引用冲突问题。

cd ~/<repo_directory/repo_name>
git remote set-url origin <bitbucket_URL>
git push --mirror

确保你已经删除了分支,而不仅仅是 PR。如果 ref 显示在您的本地,您可以 运行 git fetch --prune 删除本地不在您的遥控器上的 ref。您可能还想 运行 git gc 删除孤立的对象作为后续行动。

Is there a way to clear this PR in the remote repository?

根据您的日志,

remote: Resolving deltas: 100% (6545/6545), done.
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/2/from
remote:         refs/pull-requests/2/merge
remote:         refs/pull-requests/5/from
remote:         refs/pull-requests/5/merge

Bitbucket 不会让您通过 Git 访问那些引用。如何删除它们是 Bitbucket 支持的问题。请参阅 了解权威背景。

我终于用以下命令解决了 ref 问题:

git show-ref | cut -d' ' -f2 | grep 'pull-request' | xargs -r -L1 git update-ref -d

并通过以下方式确认清洁:

git show-ref