简体   繁体   English

Android Studio - 从GitHub结帐a * branch *

[英]Android Studio - checkout a *branch* from GitHub

We have a repo in GitHub which has 3 branches. 我们在GitHub有一个回购,它有3个分支。 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. 当我在Android Studio中检出这个仓库时,它似乎只检查分支,忽略所有其他分支。 (Eclipse used to ask us which branch to checkout/import when we are cloning a repo from GitHub) (当我们从GitHub克隆一个repo时,Eclipse曾经问过我们要检查/导入哪个分支)

The question is : How can we select a branch at the time of checking out a repo into Android Studio? 问题是 :我们如何在检查到Android Studio的回购时选择一个分支?

Image 1- Checking out from GitHub 图1-从GitHub退房

从GitHub退房

Image 2- It just asks for the repo URL, but NOT a branch. 图2-它只是要求repo URL,但不是分支。

它只是要求repo URL,但** ** **分支。

In VCS menu, you choose git and click branch to choose which branch you want to use. 在VCS菜单中,选择git并单击分支以选择要使用的分支。

在此输入图像描述

Or click right bottom corner git menu. 或者单击右下角的git菜单。

在此输入图像描述

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 在AndroidStudio中你还有终端(工具 - >打开终端,或者查看 - >工具窗口 - >终端),打开它,当前目录将直接在你的项目中,然后执行

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. 我建议你使用它: http//martinfitzpatrick.name/article/add-git-branch-name-to-terminal-prompt-mac/它会更容易看到你在哪个分支,直接在终点站。

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] 只需点击一下即可到达VCS-GIT-Branches - 在GIT的右下角:[当前分支名称]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM