为什么我不能从我的远程分支中拉取?

Why can't I pull from my remote branch?

[console]: git remote -v
origin git@testServer.com:myProj/myProj.git(fetch)
origin git@testServer.com: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

我最初创建了这个分支,并且已经推动了一段时间。虽然昨天我确实从另一个分支变基到我的分支所以可能搞砸了什么?

正确的语法是git pull origin myBranch 命令的第一个参数应该是遥控器的名称,如错误 fatal: 'origin/myBranch' does not appear to be a git repository

所建议的那样

你的语法错误:它是 git pull [ <em>remote</em> [ <em>branch-name</em> ] ],不是git pull <em>remote</em>/<em>branch-name</em> <em>branch -名称</em>。在这种情况下,您需要 git pull origin myBranch.

也就是说,我建议 不要 使用 git pull,至少在您非常熟悉 Git 之前不要使用。原因是git pull做了两件事,它做的第二件事是运行git merge,也就是:

  • 可能无法自动发生,中途停止,需要您的帮助;
  • 产生 ,这是一种倒退,每当它进行真正的合并时;
  • 通常比 git rebase 做得更好。

git pull的前半部分是git fetch,所以你可以直接运行git fetch然后,成功后,运行或者git mergegit rebase 根据需要。这两个命令都采用比 git pull.

更合理的参数

使用 git fetch,您命名要从中获取的遥控器,例如 git fetch origin(或者让 git fetch 弄清楚:git fetch 通常不带参数弄清楚自动使用 origin)。

对于 git mergegit rebase,您命名 origin/myBranch 远程跟踪分支,或者让 Git 再次解决。

综上所述,git pull 通常也会自行解决所有这些问题。特别是如果 git mergegit rebase 可以想出使用 origin/myBranchgit pull 可以想出使用 originorigin/myBranch 作为其两个步骤.