git - 为什么我不能从我的远程分支中 pull ?

标签 git branch git-rebase git-pull

[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

我最初创建了这个分支并且已经 push 了一段时间。虽然昨天我确实从另一个分支 rebase 到我的分支,所以也许这搞砸了什么?

最佳答案

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

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

  • 可能无法自动发生,中途停止,需要您的帮助;
  • 生产 "foxtrot merges" ,这有点倒退,每当它进行真正的 merge 时;
  • 通常最好写成git rebase无论如何。

上半年git pullgit fetch , 所以你可以运行 git fetch然后,在它成功之后,运行 git mergegit rebase如预期的。这两个命令的参数都比 git pull 合理得多。 .

git fetch ,您命名要从中获取的 Remote ,例如 git fetch origin (或者让 git fetch 计算出来:不带参数的 git fetch 通常会自动计算出使用 origin)。

同时git mergegit rebase , 你命名为 origin/myBranch远程跟踪分支,或者让 Git 再次解决。

所有这一切还说,git pull通常也会自己解决所有这些问题。特别是如果 git mergegit rebase可以弄清楚使用origin/myBranch , git pull可以弄清楚使用originorigin/myBranch对于它的两个步骤。

关于git - 为什么我不能从我的远程分支中 pull ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37486438/

相关文章:

git - rebase 时什么是内联 merge

git - git log --follow 已重命名的目录有技巧吗?

git - 与 git branch --set-upstream 相反

git - 我可以在 Git 中删除分支后恢复它吗?

从 PROD 合并到 HEAD 还是从 HEAD 合并到 PROD?

git - 无法恢复的 git 推送?

git - 在 Git 中生成特定提交的差异文件

Git 子模块 : Is it possible to have more than one URL for each?

git - "git pull --rebase"导致 "Cannot rebase onto multiple branches"

git - 使用 git 追加分支提交