git clone remote Branch

Source: Internet
Author: User

Sometimes git clones come down with a lot of branch, and the trouble is that if the main branch doesn't have code then you can only see the. git directory. As in the following:

$ git clonegit://gitorious.org/android-eeepc/mesa.git

Discover that there is only one. Git directory on the local, so this time you need to checkout.

Enter your local directory, as this is Mesa, using

$ git branch–r

View branch information (of course you can also use Git show-branch to view, but sometimes not good), get the following branch information:

Origin/android
Origin/mesa-es
Origin/mesa-es-dri

At this point we need the code of the Android branch, then the checkout is going to be done.

$ git checkout origin/android

Do you see the code in your catalog (MESA) again? The other branch the same.

git clone defaults to clone the remote repository as a whole; T2 {0 T, L + @0 U "C2 g) I
But only one master branch is created locally by default
If there are other branches in the remote, then use Git branch-a to see all the branches:

    1. * Master
    2. Remotes/origin/head, Origin/master "A4 U3 ~+ n5 U5 \7 R" Z (d# J
    3. Remotes/origin/master
    4. Remotes/origin/python_mail.skin
    5. Remotes/origin/udisk
    6. Remotes/origin/vip
Copy Code

Can see all the branches of the remote, such as Remotes/origin/python_mail.skin e Y ' X9 ~, F1 |
You can use the checkout command to take a remote branch locally and automatically establish a tracking

    1. $ git checkout-b python_mail.skin origin/python_mail.skin) x& x:i3 Q;? 9 J9 T5 @; j/m
    2. Branch Python_mail.skin set up to track remote Branch Python_mail.skin from Origin.; i/b! ^3 J # U6 A (}. i$ M-i
    3. Switched to a new branch ' Python_mail.skin '
Copy Code

or using the-t parameter, it defaults to a local branch with the same name as the remote branch
Collapse Expand Copy Code

    1. $ git checkout-t origin/python_mail.skin
Copy Code

You can also use fetch to do:

    1. $ GIT fetch origin Python_mail.skin:python_mail.skin
Copy Code

However, the local branch created by the FETCH command is not a track branch, and will not automatically switch to that branch after success-Z) t:r4 P-S6 _2 D3 A
Note: Do not use the following methods locally:

    1. $ git Branch Python_mail.skin
    2. $ git checkout python_mail.skin/i8 z/n: a% v/q: M
    3. $ GIT pull Origin Python_mail.skin:python_mail.skin
Copy Code

Because, the branch is built on the basis of master, and then pull down, will be merged with Master's content, there may be conflicts

git clone remote Branch

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.