How to use git with Intellij IDEA

Today we are going to use Git with Intellij.

First you need a repository with git. (If you don’t know to do that please create empty repository on github and you’ll see the instructions) Let’s Open that project with IDEA.

The first thing I want to do is remove unwanted files going to git. For example .idea folder, .iml file etc. For that we need to add .ignore plugin to the IDEA. so

File -> Settings -> Plugins 

Then search for .ignore plugin the click Search in repositories

The Click Install it. After that you’ll need to restart the IDEA.

After that we need to add .gitignore file to describe, what are the files we need to remove from tracking. First Add .gitignore file to project root.

And type the file names to ignore.

Let’s see how to commit changes. Let’s think that I changed the First I need to add it (Or any thing you want to add). Easiest way is Use Right click -> Git -> Add

Now Let’s Commit it. Here I commit whole project. (You can use right click and add commit only a file)

As you can see, on upper dialog box you can see which files you need to commit. You’ll need to give commit message. Right side, there are some functionalities if you want to execute before commit.  If everything looks clear press commit. Now we need to Push it.

VCS -> Git -> Push 

Then  you can see below dialog box.

Next window you need to give GitHub credentials.

If push successful, you can see below message in Left bottom corner.

If we went to github and check commits on relevant repository, you can see the commit there.

About Author:

Leave A Comment

Your email address will not be published. Required fields are marked *