Http://www.open-open.com/lib/view/open1328069889514.html
From Remote BranchCheckout
The local branch is called _ tracking branch )_. A trace branch is a local branch that is directly associated with a remote branch. EnterGit push
, Git will automatically infer which branch of the server to which data should be pushed. In turn, run in these branchesGit
Pull
All remote indexes are obtained and their data is merged into the local branch.
When cloning a repository, git usually automatically createsMaster
To trackORIGIN/Master
. This is exactlyGit push
AndGit pull
The reason for normal operation at the beginning. Of course, you can set it to another tracking branch as you like, suchOrigin
ExceptMaster
Other branches. We have seen an example like this:Git
Checkout-B [branch name] [remote name]/[branch name]
.
Shuohailhl @ SHUOHAILHL-PC/f/ggg/Jingwei (master) $ git checkout-track origin/br-2.1.2.1Branch 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.1nothing to commit, working directory cleanshuohailhl @ SHUOHAILHL-PC/f/ggg/Jingwei (br-2.1.2.1) $ git Br * br-2.1.2.1 br-2.1.2.2 mastershuohailhl @ SHUOHAILHL-PC/f/ggg/Jingwei (br-2.1.2.1)
Delete the branch of the track.
Shuohailhl @ SHUOHAILHL-PC/f/ggg/Jingwei (master) $ git BR br-2.1.2.1 br-2.1.2.2 * mastershuohailhl @ SHUOHAILHL-PC/f/ggg/Jingwei (master) $ git status # on Branch masternothing to commit, working directory cleanshuohailhl @ SHUOHAILHL-PC/f/ggg/Jingwei (master) $ git branch-D br-2.1.2.1warning: 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. 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] upgrade meta client 2.1.4.4 * master 89700a3 optimize Upload File
Use the checkout command to create a new branch br-2.1.2.1 that tracks remote origin/br-2.1.2.1
Shuohailhl @ 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.1nothing to commit, working directory cleanshuohailhl @ SHUOHAILHL-PC/f/ggg/Jingwei (br-2.1.1.1) $ git branch-A * br-2.1.1.1 br-2.1.2.2 br-2.1.2.1 master remotes/ORIGIN/head-> origin/Master remotes/ORIGIN/br-2.1.2.2 remotes/ORIGIN/br-2.1.3 remotes/ORIGIN/Master