我尝试将我的本地分支(local_dev)中的更改推送到远程分支(开发),我使用下面的命令,但是在执行命令后它给了我一个意外的消息。
$ git push origin local_dev :develop
命令执行后的消息:
Counting objects: 1941, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (838/838), done.
Writing objects: 100% (1378/1378), 265.47 KiB | 0 bytes/s, done.
Total 1378 (delta 604), reused 863 (delta 257)
remote: error: refusing to delete the current branch: refs/heads/develop
To https://github.com/MyCompany/MyProject.git
* [new branch] local_dev -> local_dev
! [remote rejected] develop (deletion of the current branch prohibited)
error: failed to push some refs to 'https://github.com/MyCompany/MyProject.git'
有关为什么会发生这种情况的任何建议?
感谢。
答案 0 :(得分:1)
refspec中有空格。它应该是这样的:
git push origin local_dev:develop
而不是这个
git push origin local_dev :develop
因为那个空间在那里,你给了git push
两个refspecs,而不是一个。第一个规范说"将local_dev
推送到名为local_dev
"的遥控器。第二个规范说:develop
,由于:
的左侧是空的,它表示"删除远程develop
分支"。这就是您在git push
输出中获得最后一行的原因:
! [remote rejected] develop (deletion of the current branch prohibited)
有关使用:<branch>
语法删除分支的详细信息,请阅读