问题
Backround:
Suppose I have the following Git URLs (hosted on github)
http://github.com/mikl/drupal.git
git://github.com/mikl/drupal.git (Git read-only)
I am interested in having a local copy of this repository so I can pratice working with branches in git and see how my local working tree can change depending on which branch I am working with.
Questions:
- To get started, I set up a local directory and do git clone git://github.com/mikl/drupal.git ... Will this clone all of the branches? Or will it only clone master?
- The web front-end for github gives me a "drop down" menu that allows me to switch branches ... Does changing this drop-down actually change which branch I will be grabbing when I run git clone?
- If I want a new copy of this repository on my local machine, but I am interested in only two branches of this repository and I want to ignore all the rest, what command do I use to ensure I clone only those two branches and nothing else (assume one of the branches is master)?
回答1:
- It will clone all of the branches. However, there will be no local branches created for anything but master. You can view the remote branches with
git branch -rand create a local tracking branch withgit branch localname origin/remotename - No.
- A multi-step process, which I suggest you don't bother with (create repository, set up a remote, do partial fetches of the remote).
来源:https://stackoverflow.com/questions/2807098/git-tutorial-understanding-git-pull-and-branches-using-a-specific-example-repo