当你这么做的时候
git pull origin test-branch
它实际上会把变化从
origin
遥远的
master
分支并将它们合并到当前签出的分支中。
本地签出远程分支并设置跟踪
git fetch
git checkout --track origin/test-branch
这将基本上实现以下功能:
-
git fetch
将更新到远程
-
创建一个名为
test-branch
-
安装程序
origin/test-branch
作为远程跟踪分支
-
将本地分支设置为
起源/测试分支
从git手册:
-t, --track
When creating a new branch, set up "upstream" configuration. See "--track" in git-branch(1) for details.
If no -b option is given, the name of the new branch will be derived from the remote-tracking branch, by looking at the local part of the refspec configured for the corresponding remote, and then stripping the
initial part up to the "*". This would tell us to use hack as the local branch when branching off of origin/hack (or remotes/origin/hack, or even refs/remotes/origin/hack). If the given name has no slash, or the
above guessing results in an empty name, the guessing is aborted. You can explicitly give a name with -b in such a case.
这基本上意味着如果你的远程分支被调用
起源/测试分支
它将调用本地创建的分支
测试分支
.
显示跟踪的分支的步骤
git status
将在第二行显示它正在跟踪的远程设备
git branch -vv
将向您显示本地分支的列表,以及它们正在跟踪的远程分支
看看这个
stackoverflow answer
想知道更详细的答案。