问题
We have a repo in GitHub which has 3 branches. For example, say master, developer and preview.
When I checkout this repo in Android Studio, it seems to checkout the master branch only, ignoring all other branches. (Eclipse used to ask us which branch to checkout/import when we are cloning a repo from GitHub)
The question is : How can we select a branch at the time of checking out a repo into Android Studio?
Image 1- Checking out from GitHub
Image 2- It just asks for the repo URL, but NOT a branch.
回答1:
In VCS menu, you choose git and click branch to choose which branch you want to use.
Or click right bottom corner git menu.
回答2:
In AndroidStudio you have also the terminal (Tools --> Open Terminal, or View --> Tool Windows --> Terminal), open it, the current directory will be directly your project's, then just execute
git checkout the_name_of_the_branch
and that's all.
I would recommend you then to use this: http://martinfitzpatrick.name/article/add-git-branch-name-to-terminal-prompt-mac/ it will be much easier to see on which branch you are, directly in the terminal.
回答3:
The branch selection is done by two steps:
VCS-GIT-FETCH (unfetched externally created branch is invisible for you)
VCS-GIT-Branches-(Remote branches - branch name)-Checkout
The VCS-GIT-Branches can be reached by one click - in the right lower corner on GIT:[current branch name]
来源:https://stackoverflow.com/questions/17589828/android-studio-checkout-a-branch-from-github