因业务限制,需要在两个代码仓库进行周期性的同步代码。大概逻辑是使用git clone --mirror方式将源仓库中的代码clone到本地主机上,然后推送到目标仓库中。
以下代码实现了如下逻辑
参数为配置文件,逐行读取配置文件,拉取代码到临时目录,并根据源仓库替换字符串生成目标残酷地址,并将代码推送到目标仓库。完成操作后,清除所有临时文件。
以上代码一直正常使用,直到今天,突然报错,
提示 The keywords cherry-pick and revert are branch names reserved by CodeHub, You are not allowed to create.并且所有的分支都被拒绝 (pre-receive hook declined)
手动clone代码并重新设定remote
git clone --mirror aaaaa
git reote add repo bbbbb
查看所有分支
git branch -a
可以看到tmp开头的分支,此分支为代码合并期间的临时分支。
查看源仓库,发现有为完成的合并请求。
在本地删除此分支
git branch -D tmp-branch-xxxx
重新push
git push repo +refs/heads/*:refs/heads/*
问题解决