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:
- * Master
- Remotes/origin/head, Origin/master "A4 U3 ~+ n5 U5 \7 R" Z (d# J
- Remotes/origin/master
- Remotes/origin/python_mail.skin
- Remotes/origin/udisk
- 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
- $ git checkout-b python_mail.skin origin/python_mail.skin) x& x:i3 Q;? 9 J9 T5 @; j/m
- Branch Python_mail.skin set up to track remote Branch Python_mail.skin from Origin.; i/b! ^3 J # U6 A (}. i$ M-i
- 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
- $ git checkout-t origin/python_mail.skin
Copy Code
You can also use fetch to do:
- $ 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:
- $ git Branch Python_mail.skin
- $ git checkout python_mail.skin/i8 z/n: a% v/q: M
- $ 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, it will be merged with Master's content, there may be a rush
git clone branch