git 为什么我不能从我的远程分支拉?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37486438/
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
Why can't I pull from my remote branch?
提问by Grammin
[console]: git remote -v
origin [email protected]:myProj/myProj.git(fetch)
origin [email protected]:myProj/myProj.git(push)
[console]: git branch -a
*myBranch
development
remotes/origin/myBranch
remotes/origin/development
[console]: git pull origin/myBranch myBranch
fatal: 'origin/myBranch' does not appear to be a git repository
fatal: Could not read from remote repository
I originally made this branch and have been pushing to it for a while. Although yesterday I did rebase from another branch into my branch so maybe that messed something up?
我最初制作了这个分支,并且已经推动了一段时间。虽然昨天我确实从另一个分支变基到了我的分支,所以也许这搞砸了?
回答by torek
You have the syntax wrong: it's git pull [ remote[ branch-name] ]
, not git pull remote/branch-namebranch-name
. In this case you would need git pull origin myBranch
.
您的语法错误:它是,不是。在这种情况下,您需要.git pull [ remote[ branch-name] ]
git pull remote/branch-namebranch-name
git pull origin myBranch
That said, I recommend notusing git pull
at all, at least not until you are very familiar with Git. The reason is that git pull
does two things, and the second thing it does is run git merge
, which:
也就是说,我建议完全不要使用git pull
,至少在您非常熟悉 Git 之前不要使用。原因是它git pull
做了两件事,它做的第二件事是 run git merge
,它:
- can fail to happen automatically, stop in the middle, and need help from you;
- produces "foxtrot merges", which are sort of backwards, whenever it makes a real merge;
- is usually better done as
git rebase
anyway.
- 可能会自动失败,中途停止,需要您的帮助;
- 产生"foxtrot merges",这是一种倒退,每当它进行真正的合并时;
- 通常最好这样做
git rebase
。
The first half of git pull
is git fetch
, so you can just run git fetch
and then, after it succeeds, run either git merge
or git rebase
as desired. Both of these commands take much more sensible arguments than git pull
.
的前半部分git pull
是git fetch
,因此您可以直接运行git fetch
,然后在成功后运行git merge
或git rebase
根据需要运行。这两个命令都比git pull
.
With git fetch
, you name the remote to fetch from, e.g., git fetch origin
(or just let git fetch
figure it out: git fetch
with no arguments will generally figure out to use origin
automatically).
使用git fetch
,您可以命名要从中获取的遥控器,例如,git fetch origin
(或者只是git fetch
弄清楚:git fetch
没有参数通常会origin
自动计算出使用)。
With both git merge
and git rebase
, you name the origin/myBranch
remote-tracking branch, or just let Git figure it out, again.
使用git merge
和git rebase
,您可以命名origin/myBranch
远程跟踪分支,或者让 Git 再次弄清楚。
All that also said, git pull
will usually figure all of these out on its own as well. In particular if git merge
or git rebase
can figure out to use origin/myBranch
, git pull
can figure out to use origin
and origin/myBranch
for its two steps.
所有这些也说,git pull
通常也会自己解决所有这些问题。尤其是如果git merge
或git rebase
能算出使用origin/myBranch
、git pull
能算出使用origin
和origin/myBranch
为其两个步骤。
回答by Flows
The correct syntax is git pull origin myBranch
The first argument of the command should be the name of the remote, as suggested by the error fatal: 'origin/myBranch' does not appear to be a git repository
正确的语法是git pull origin myBranch
命令的第一个参数应该是远程的名称,如错误所建议的fatal: 'origin/myBranch' does not appear to be a git repository