git - 为什么我 pull 的时候需要一直做 `--set-upstream-to`?

标签 git git-branch git-pull

我通常必须克隆我的 git 存储库中没有的远程分支(例如来自同事)

虽然 git push 有一个简单的设置(参见 Why do I need to do `--set-upstream` all the time? ) 我还没有发现 git pull 也是如此。

现在我的工作流程是:

  • 哦,我必须从 github 的 projectABC pull branch123
  • cd projectABC && git checkout -b branch123
  • git pull

唉,迎接我的是:

There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details.

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=origin/<branch> branch123

我怎样才能使这更容易?

最佳答案

当您使用 -b 标志进行 checkout 时,您实际上创建了一个新的本地分支,而不是链接到任何远程分支。第一次推送新分支时,可以通过执行 git push -u 将其链接到新的远程分支。如果您正在 checkout 现有分支,只需删除 -b

关于git - 为什么我 pull 的时候需要一直做 `--set-upstream-to`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52662736/

相关文章:

git - 如何在一个已经挂起时发出第二个 github pull 请求

git - 项目中每个人的默认 git 预提交 Hook ?

git - 是否有对上游分支的引用?

git - 默认的 git divergent merge 策略是什么?

git - 如何使现有分支成为git中的孤儿

git - 如何从另一个分支获取一个文件?

git - 为什么需要 git pull 来更新(不同的)分支(将分支移动到最新的提交而无需 git pull)?

git - 是否可以让某人成为已推送到 GitHub 的过去提交的共同作者?

git diff 用于存储中的单个文件

eclipse - Git bash win32异常 : Failed to write credentials