git pull 远程分支找不到远程引用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11552437/
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 pull remote branch cannot find remote ref
提问by Crystal
I'm not sure why this doesn't work. When I do git branch -a
, this is what I see:
我不确定为什么这不起作用。当我这样做时git branch -a
,这就是我所看到的:
I'm trying to pull from the DownloadManager on the online GitHub repository. I have tried
我正在尝试从在线 GitHub 存储库上的 DownloadManager 中提取。我试过了
- git pull, but then it complains about not knowing which branch to pull from
- git pull origin, doesn't know which branch
- git pull origin downloadmanager
fatal: Couldn't find remote ref downloadmanager. Unexpected end of commands stream
- git pull origin remotes/origin/DownloadManager
'fatal couldn't find remote ref remotes/origin/DownloadManager. Unexpected end of commands stream
- git pull,然后它抱怨不知道从哪个分支拉取
- git pull origin,不知道哪个分支
- git pull origin 下载管理器
fatal: Couldn't find remote ref downloadmanager. Unexpected end of commands stream
- git pull origin remotes/origin/DownloadManager
'fatal couldn't find remote ref remotes/origin/DownloadManager. Unexpected end of commands stream
Is there something I'm missing? In Xcode, When I try to connect to the repository, nothing ever shows up. I have been able to push to it in the past. But I can't push again until I pull the most recent changes.
有什么我想念的吗?在 Xcode 中,当我尝试连接到存储库时,什么也没有显示。过去我一直能够推动它。但是在我拉出最近的更改之前,我无法再次推动。
回答by radistao
Be careful - you have case mixing between local and remote branch!
小心 - 您在本地和远程分支之间存在大小写混合!
Suppose you are in local branch downloadmanagernow (git checkout downloadmanager
)
假设您现在在本地分支downloadmanager( git checkout downloadmanager
)
You have next options:
您有以下选择:
Specify remote branch in pull/pushcommands every time (case sensitive):
git pull origin DownloadManager
or
git pull origin downloadmanager:DownloadManager
每次在pull/push命令中指定远程分支(区分大小写):
git pull origin DownloadManager
或者
git pull origin downloadmanager:DownloadManager
Specify tracking branch on next push:
git push -u origin DownloadManager
(-uis a short form of --set-upstream)
this will persist downloadmanager:DownloadManagerlink in config automatically (same result, as the next step).
在下一次推送时指定跟踪分支:
git push -u origin DownloadManager
(-u是--set-upstream的缩写形式)
这将自动在配置中保留downloadmanager:DownloadManager链接(结果与下一步相同)。
Set in git config default remote tracking branch:
git branch -u downloadmanager origin/DownloadManager
(note, since git 1.8 for branchcommand -uis a short form of --set-upstream-to, which is a bit different from deprecated --set-upstream)
or edit config manually (I prefer this way):
git config --local -e
-> This will open editor. Add block below (guess, after "master" block):
[branch "downloadmanager"] remote = origin merge = refs/heads/DownloadManager
在 git config 默认远程跟踪分支中设置:
git branch -u downloadmanager origin/DownloadManager
(请注意,由于分支命令-u 的git 1.8是--set-upstream-to的缩写形式,这与已弃用的--set-upstream略有不同)
或手动编辑配置(我更喜欢这种方式):
git config --local -e
-> 这将打开编辑器。在下面添加块(猜测,在“主”块之后):
[branch "downloadmanager"] remote = origin merge = refs/heads/DownloadManager
and after any of those steps you can use easily:
在这些步骤中的任何一个之后,您都可以轻松使用:
git pull
git pull
If you use TortoiseGit: RightClick on repo -> TortoiseGit -> Settings -> Git -> Edit local .git/config
如果你使用 TortoiseGit:右键单击 repo -> TortoiseGit -> Settings -> Git -> Edit local .git/config
回答by Chris Halcrow
The branch name in Git is case sensitive. To see the names of your branches that Git 'sees' (including the correct casing), use:
Git 中的分支名称区分大小写。要查看 Git“看到”的分支名称(包括正确的大小写),请使用:
git branch -vv
... and now that you can see the correct branch name to use, do this:
...现在您可以看到要使用的正确分支名称,请执行以下操作:
git pull origin BranchName
where 'BranchName' is the name of your branch. Ensure that you match the case correctly
其中 'BranchName' 是您的分支名称。确保您正确匹配案例
So in the OP's (Original Poster's) case, the command would be:
因此,在 OP(原始海报)的情况下,命令将是:
git pull origin DownloadManager
回答by rubo77
If none of these answers work, I would start by looking in your .git/config
file for references to the branch that makes problems, and removing them.
如果这些答案都不起作用,我将首先在您的.git/config
文件中查找对产生问题的分支的引用,然后将其删除。
回答by UWU_SANDUN
This error happens because the local repository can't identify the remote branch at first time. So you need to do it first. It can be done using following commands:
发生此错误是因为本地存储库第一次无法识别远程分支。所以你需要先做。可以使用以下命令完成:
git remote add origin 'url_of_your_github_project'
git push -u origin master
回答by joshua pogi 28
check your branch on your repo. maybe someone delete it.
在您的回购中检查您的分支。也许有人删除它。
回答by Nilesh leve
For me, it was because I was trying to pull a branch which was already deleted from Github.
对我来说,这是因为我试图拉一个已经从 Github 中删除的分支。
回答by Matt Gibson
You need to set your local branch to track the remote branch, which it won't do automatically if they have different capitalizations.
您需要设置本地分支以跟踪远程分支,如果它们的大小写不同,则不会自动执行此操作。
Try:
尝试:
git branch --set-upstream downloadmanager origin/DownloadManager
git pull
UPDATE:
更新:
'--set-upstream' option is no longer supported.
不再支持“--set-upstream”选项。
git branch --set-upstream-to downloadmanager origin/DownloadManager
git pull
回答by Tim
This is because your remote branch name is "DownloadManager“, I guess when you checkout your branch, you give this branch a new name "downloadmanager".
这是因为你的远程分支名称是“DownloadManager”,我猜当你结账你的分支时,你给这个分支一个新名称“downloadmanager”。
But this is just your local name, not remote ref name.
但这只是您的本地名称,而不是远程引用名称。
回答by testing devops
I had this issue when after rebooted and the last copy of VSCode reopened. The above fix did not work, but when I closed and reopened VSCode via explorer it worked. Here are the steps I did:
在重新启动并重新打开 VSCode 的最后一个副本后,我遇到了这个问题。上述修复不起作用,但是当我通过资源管理器关闭并重新打开 VSCode 时,它起作用了。以下是我做的步骤:
//received fatal error
git remote remove origin
git init
git remote add origin git@github:<yoursite>/<your project>.git
// still received an err
//restarted VSCode and folder via IE
//updated one char and resaved the index.html
git add .
git commit -m "blah"
git push origin master