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:
however there is no option to submit the specific branch.
Is there anyway to clone a specific branch using Git in Intellij?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With