我通常必须克隆我的 git 存储库中没有的远程分支(例如来自同事)
虽然 git push
有一个简单的设置(参见 Why do I need to do `--set-upstream` all the time? )
我还没有发现 git pull 也是如此。
现在我的工作流程是:
- 哦,我必须从 github 的
projectABC
pullbranch123
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/