How to create a Java Project as a Git Repository with IntelliJ


If you are about to start with a new Java project in IntelliJ IDE and you want that project to be in a Git repository, follow the below steps,

  1. Open the IntelliJ IDE (I am using the Community Edition)
  2. Click on the New Project button.
    Creating a new Java Project in IntelliJ
  3. Select Empty Project from side bar.
  4. Add the name of the project.
  5. Make sure to click on "Create Git repository".
    Create Git repository intelliJ
  6. Click create.

You will see that the project has a git branch created with a local main branch.

Once you create the first file for the project you will be prompted with "Do you want to add the following file to Git?"

Prompt - Do you want to add the following file to Git - intelliJ

Converting Existing non-version controlled Project into a Git Project

If you have an existing project that is not version controlled, you can simply open the project in IntelliJ and click on "Version Control" on the status bar and select the "Create a Git repository" option to convert it into a git repo.

Convert Existing Project to Git Project IntelliJ

Once the project is converted to a Git repo, you will see that the "Version Control" has changed to "Git"

The project is now converted to Git Project

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap