Git push不工作但git pull在远程分支上工作

时间:2011-12-09 14:58:01

标签: git github

我团队中的一位开发人员遇到了以下问题。他们有能力拉出一个远程分支,说它是最新的,但他们无法推送到那个远程分支。以下是他们在Windows git命令提示符

中获得的内容
MY@MY-PC ~/documents/workspace/my-repository (workflowNewCOBRequest1)
$ git remote show origin workflowNewCOBRequest1
Enter passphrase for key '/c/Users/MY/.ssh/id_rsa':
* remote origin
  Fetch URL: git@github.com:myorg/my-repository.git
  Push  URL: git@github.com:myorg/my-repository.git
  HEAD branch: master
  Remote branches:
    2_Initial_COB_Submission tracked
    COB_VF_email_template    new (next fetch will store in remotes/origin)
    Team-approval            tracked
    develop                  tracked
    master                   tracked
    testing                  tracked
    workflowNewCOBRequest1   tracked
  Local branches configured for 'git pull':
    develop                merges with remote develop
    master                 merges with remote master
    workflowNewCOBRequest1 merges with remote workflowNewCOBRequest1
  Local refs configured for 'git push':
    Team-approval pushes to Team-approval (up to date)
    develop       pushes to develop       (local out of date)
    master        pushes to master        (up to date)

MY@MY-PC ~/documents/workspace/my-repository (workflowNewCOBRequest1)
$ git push origin workflowNewCOBRequest1
Enter passphrase for key '/c/Users/MY/.ssh/id_rsa':
fatal: workflowNewCOBRequest1 cannot be resolved to branch.
fatal: The remote end hung up unexpectedly

我在互联网上搜索过,找不到类似的东西。有什么想法吗?

由于

3 个答案:

答案 0 :(得分:12)

我使用旧版本的git

时遇到了类似的问题

git version

并与没有问题的人进行比较

虽然,在这里看起来问题是你没有本地REF将该分支推回原点。

这有用吗?它明确指出要推送到(和来自)

的分支
git push origin workflowNewCOBRequest1:workflowNewCOBRequest1

答案 1 :(得分:1)

我花了一个小时尝试各种各样的东西 - 没有办法摆脱错误。最后,我决定删除本地仓库 - 并再次克隆远程仓库。然后一切都开始正常工作。不理想 - 但会奏效。

答案 2 :(得分:0)

取决于存储库,可能需要在推送之前创建新分支。我在主分支上,不得不从我上一次提交中创建一个新的brach。 How to create a new branch from a previous commit

这对我有用。