Intellij git:克隆特定分支

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43589958/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:43:38  来源:igfitidea点击:

Intellij git: clone specific branch

gitintellij-ideaversion-controlbranchclone

提问by Daniel Fensterheim

I am new to Intellij. I need to create a new project based on a specific git branch. I selected: File->new->Project from Version Control->Git however there are only 3 fields which result in cloning the master branch:

我是 Intellij 的新手。我需要基于特定的 git 分支创建一个新项目。我选择了:File->new->Project from Version Control->Git 但是只有 3 个字段会导致克隆 master 分支:

  • Git Repository URL
  • Parent Directory
  • Directory Name
  • Git 存储库 URL
  • 父目录
  • 目录名称

however there is no option to submit the specific branch.

但是没有提交特定分支的选项。

Is there anyway to clone a specific branch using Git in Intellij?

无论如何,是否可以在 Intellij 中使用 Git 克隆特定分支?

回答by Luca Galasso

As Vampire say, you have to clone all the git project, then change branch. You can change the branch pressing on bottom-right > Git:master > Remote Branches > chose your branch > Checkout as new local branch

正如 Vampire 所说,您必须克隆所有 git 项目,然后更改分支。您可以更改右下角的分支 > Git:master > Remote Branches > 选择您的分支 > Checkout as new local branch

回答by Vampire

You misunderstood Git. In Git as in any DVCS by default you clone the full repository including all branches. Only for the default branch of the cloned repository (most often this is master), there is a local branch created autmatically and checked out. But you still have all branches of the cloned repository present as remote tracking branches in your local repository. So just checkout the branch you want after you did the clone. If you clone with the commandline instead, you can give the clone command the branch that should be checked out after the clone automatically if different from the default branch, but IJ does not have an option for that apparently. But switching the branch after the cloning is easy.

你误解了 Git。在 Git 中和在任何 DVCS 中一样,默认情况下您克隆完整的存储库,包括所有分支。仅对于克隆存储库的默认分支(通常是master),有一个自动创建并签出的本地分支。但是您仍然将克隆存储库的所有分支作为本地存储库中的远程跟踪分支存在。因此,只需在完成克隆后签出所需的分支即可。如果您改为使用命令行进行克隆,如果与默认分支不同,您可以为克隆命令提供应该在克隆后自动检出的分支,但 IJ 显然没有选项。但是克隆后切换分支很容易。

回答by Bharath

First you do checkout from master, once done go right side bottom corner, and Click on Git, popup will open , click on show more,it will populate all branches in remote Branches. ( better drag and maximize that box) . and select your required branch from Remote Branches and do check out. Automatically your selected branch will come as your project in intellij. Image of Inttelij Bottom Location

首先从 master 结帐,完成后转到右下角,然后单击 Git,将打开弹出窗口,单击显示更多,它将填充远程分支中的所有分支。(更好地拖动并最大化该框)。并从远程分支中选择您需要的分支并签出。您选择的分支将自动作为您在 intellij 中的项目。Inttelij 底部位置的图像

Select Show more Option

选择显示更多选项

Do Check your required branch

请检查您所需的分支