Git obtains the remote branch locally and establishes the association track

Source: Internet
Author: User

Http://www.open-open.com/lib/view/open1328069889514.html

From Remote BranchCheckoutThe 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 createsMasterTo trackORIGIN/Master. This is exactlyGit pushAndGit pullThe reason for normal operation at the beginning. Of course, you can set it to another tracking branch as you like, suchOriginExceptMasterOther 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.