http://blog.csdn.net/arkblue/article/details/9790129
从远程分支 checkout 出来的本地分支,称为_跟踪分支(tracking branch)_。跟踪分支是一种和远程分支有直接联系的本地分支。在跟踪分支里输入Git push,Git 会自行推断应该向哪个服务器的哪个分支推送数据。反过来,在这些分支里运行git pull 会获取所有远程索引,并把它们的数据都合并到本地分支中来。在克隆仓库时,Git 通常会自动创建一个名为 master 的分支来跟踪 origin/master。这正是git push 和 git pull 一开始就能正常工作的原因。当然,你可以随心所欲地设定为其它跟踪分支,比如origin 上除了 master 之外的其它分支。刚才我们已经看到了这样的一个例子:git checkout -b [分支名] [远程名]/[分支名]。[plain] view plain copyshuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (master) $ git checkout --track origin/br-2.1.2.1 Branch br-2.1.2.1 set up to track remote branch br-2.1.2.1 from origin. Switched to a new branch 'br-2.1.2.1' shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.1) $ git status # On branch br-2.1.2.1 nothing to commit, working directory clean shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.1) $ git br * br-2.1.2.1 br-2.1.2.2 master shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.1) 删掉刚才track的分支[plain] view plain copyshuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (master) $ git br br-2.1.2.1 br-2.1.2.2 * master shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (master) $ git status # On branch master nothing to commit, working directory clean shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (master) $ git branch -d br-2.1.2.1 warning: deleting branch 'br-2.1.2.1' that has been merged to 'refs/remotes/origin/br-2.1.2.1', but not yet merged to HEAD. Deleted branch br-2.1.2.1 (was cec094b). shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (master) $ git br -v br-2.1.2.2 1dfeab3 [behind 9] 升级META客户端2.1.4.4 * master 89700a3 optimize upload file 使用checkout命令,创建新的分支 br-2.1.2.1,跟踪远程的origin/br-2.1.2.1[plain] view plain copyshuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (master) $git checkout -b br-2.1.1.1 origin/br-2.1.2.1Branch br-2.1.1.1 set up to track remote branch br-2.1.2.1 from origin. Switched to a new branch 'br-2.1.1.1' shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.1.1) $ git status # On branch br-2.1.1.1 nothing to commit, working directory clean shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.1.1) $ git branch -a * br-2.1.1.1 br-2.1.2.2 master remotes/origin/HEAD -> origin/master remotes/origin/br-2.1.2.1 remotes/origin/br-2.1.2.2 remotes/origin/br-2.1.3 remotes/origin/master