git push命令给出了意外的输出

时间:2014-05-28 17:21:15

标签: git

我尝试将我的本地分支(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'

有关为什么会发生这种情况的任何建议?

感谢。

1 个答案:

答案 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>语法删除分支的详细信息,请阅读