Github镜像:推送时如何设置默认分支



我正在关注这个https://docs.github.com/en/repositories/creating-and-managing-repositories/duplicating-a-repository#mirroring-a-repository,用于将存储库从Gitlab迁移到Github(企业(。

git clone --bare https://github.com/exampleuser/old-repository.git
cd old-repository.git
git push --mirror https://github.com/exampleuser/new-repository.git

这些步骤打包在一个脚本中,我每周运行一次。

我注意到GitHub上的默认分支被设置为随机分支,而不是git和gitlab中定义的默认分支。

假设我有一个回购X,有4个分支:

master(默认分支(
dev
feature-1
feature-2

当我第一次为新存储库运行脚本时,GitHub上的默认分支设置为feature-1
同时,开发人员将feature-1合并到dev中,并将其删除。
下次运行脚本时,它将尝试删除Github上的feature-1分支,就像在gitlab中一样,但失败并返回错误:

'![远程拒绝]功能-1234(拒绝删除当前分支:refs/heads/feature-1234(

我在推送之前尝试了git symbolic-ref HEAD refs/heads/master,但仍然没有成功。

我知道推送后我可以用github API更改默认分支设置,但我想避免这样做。

知道我该如何存档吗?

编辑
由于脚本运行位置的代理限制,避免使用Github API。

根据@torek的说法,这在客户端似乎是不可能的。推送后我会选择Gitlab API。

最新更新