可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I'm not sure why this doesn't work. When I do git branch -a, this is what I see:
I'm trying to pull from the DownloadManager on the online GitHub repository. I have tried
- 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
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.
回答1:
Be careful - you have case mixing between local and remote branch!
Suppose you are in local branch downloadmanager now (git checkout downloadmanager)
You have next options:
Specify remote branch in pull/push commands every time (case sensitive):
git pull origin DownloadManager
or
git pull origin downloadmanager:DownloadManager
Specify tracking branch on next push:
git push -u origin DownloadManager
(-u is a short form of --set-upstream)
this will persist downloadmanager:DownloadManager link in config automatically (same result, as the next step).
Set in git config default remote tracking branch:
git branch -u downloadmanager origin/DownloadManager
(note, since git 1.8 for branch command -u is 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
and after any of those steps you can use easily:
git pull
If you use TortoiseGit: RightClick on repo -> TortoiseGit -> Settings -> Git -> Edit local .git/config
回答2:
The branch name in Git is case sensitive. To see the names of your branches that Git 'sees' (including the correct casing), use:
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
So in the OP's (Original Poster's) case, the command would be:
git pull origin DownloadManager
回答3:
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
回答4:
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
回答5:
This is because your remote branch name is "DownloadManager“, I guess when you checkout your branch, you give this branch a new name "downloadmanager".
But this is just your local name, not remote ref name.
回答6:
For me, it was because I was trying to pull a branch which was already deleted from Github.