Git push 不工作,但 git pull 在远程分支上工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8447332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git push not working but git pull does work on remote branch
提问by pbattisson
One of the developers in my team is having the following issues. They have the ability to pull a remote branch which says it is all up to date, but they cannot push to that remote branch. The following is what they are getting in the Windows git command prompt
我团队中的一位开发人员遇到了以下问题。他们有能力拉出一个远程分支,表明它是最新的,但他们不能推送到那个远程分支。以下是他们在 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: [email protected]:myorg/my-repository.git
Push URL: [email protected]: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
I have searched the internet and cannot find anything resembling this. Any ideas?
我在互联网上搜索过,找不到类似的东西。有任何想法吗?
Thanks
谢谢
Paul
保罗
回答by Daniel Elliott
I had a similar problem using an old version of git
我在使用旧版本的 git 时遇到了类似的问题
try
尝试
git version
and compare with someone who is not having the issue
并与没有问题的人进行比较
Although, here it looks like the problem is that you don't have a local REF for pushing that branch back to the origin.
虽然,这里看起来问题是你没有本地 REF 来将该分支推回原点。
Does this work? It explicitly indicates which branch to push to (and from)
这行得通吗?它明确指示要推送到(和从)哪个分支
git push origin workflowNewCOBRequest1:workflowNewCOBRequest1
回答by etayluz
I spent an hour trying all sorts of stuff - nothing worked to get rid of the error. Finally, I decided to delete the local repo - and clone the remote repo again. Then everything started working just fine. Not ideal - but will work.
我花了一个小时尝试各种方法 - 没有任何方法可以消除错误。最后,我决定删除本地存储库 - 并再次克隆远程存储库。然后一切都开始工作得很好。不理想 - 但会起作用。
回答by Gregor
Depeding on the repository, you might be required to create a new branch before you can push . I was on the master branch and had to create a new brach from my last commit . How to create a new branch from a previous commit
根据存储库,您可能需要先创建一个新分支,然后才能 push 。我在 master 分支上,不得不从上次提交中创建一个新分支。 如何从以前的提交创建新分支
That worked for me.
那对我有用。