Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij git: clone specific branch

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:

  • Git Repository URL
  • Parent Directory
  • Directory Name

however there is no option to submit the specific branch.

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

like image 970
Daniel Fensterheim Avatar asked Apr 24 '17 13:04

Daniel Fensterheim


People also ask

Can you Git clone a specific branch?

There are two ways to clone a specific branch. You can either: Clone the repository, fetch all branches, and checkout to a specific branch immediately. Clone the repository and fetch only a single branch.

How do I clone down a specific branch?

In order to clone a specific branch, you have to execute “git branch” with the “-b” and specify the branch you want to clone. $ git clone -b dev https://github.com/username/project.git Cloning into 'project'... remote: Enumerating objects: 813, done.

How do I pull a specific branch from GitHub IntelliJ?

In the Branches popup, choose New Branch or right-click the current branch in the Branches pane of the Git tool window tool window and choose New Branch. In the dialog that opens, specify the branch name, and make sure the Checkout branch option is selected if you want to switch to that branch.


1 Answers

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.

like image 177
Vampire Avatar answered Sep 30 '22 08:09

Vampire