Last Updated on
This post demonstrates how to check out a specific (non-master) branch from a Git repository in IntelliJ IDEA. For this purpose, we will use the angular codebase available in Github.com.
Stuff used for this post.
- IntelliJ IDEA 2018.2.3 (Ultimate Edition)
- We have not tested with the Community Edition
- JDK 1.8
- Windows 10 Enterprise
- Latest Angular codebase
The basic idea is to check out first the master using IntelliJ IDEA via the git client that is shipped with it and choose a specific branch thereafter.
Codebase to use
We will the angular codebase available in Github.com. The version does not matter as long as it has accessible branches to for us to check out.
If we are to clone or download from the page shown below, we would get the latest codebase from the master branch.
For those who are new to git, please watch this video.
Use 5.2.x Branch
We will use this branch for this post.
Try it with IntelliJ IDEA
1. Check out master
It depends on how the IDE is opened. The following shows a typical window when no project is opened. In this case, we choose to Check out from Version Control -> Git. Alternatively, we can use File -> New -> Project from Version Control -> Git.
This then displays the following window asking for the URL to the codebase at github.com.
To verify if the URL is valid, click the Test button. Then, click the Clone button to trigger the check-out operation.
Wait until the process completes. Then use the Create project from existing sources (default) and click Next.
Choose all items and hit Finish.
Wait until the configuration completes. At the bottom-right corner of the main IDE window, there is a UI control (or simply an item) with a label Git: master. We will use this to choose another (non-master) branch.
2. Choose a specific branch
Choose a specific branch from a list of branches. The Show XX More option has to be clicked to reveal the branches.
For our purpose, we want to use 5.2.x. Click it and choose Checkout As…
Use the original branch name and click OK.
The IDE will check out that version to the local machine.
3. After successful check-out…
There are some tasks needed to be done after a successful check-out depending on the codebase. For example, for maven projects, they still need to be imported. Otherwise, the Maven Projects window is empty.