103

I try to switch from Eclipse to IntelliJ IDEA. I have a project that uses Git and I want to quickly add files to .gitignore file. In Eclipse I can right click on a file/directory and choose 'Add to .gitignore'.

Is there anything like this in IntelliJ IDEA or I have to edit the file manually?

1
  • 1
    There is a feature request regarding this, please vote if you agree ;)
    – Line
    Commented Feb 15, 2019 at 10:30

6 Answers 6

127

IntelliJ has no option to click on a file and choose "Add to .gitignore" like Eclipse has.

The quickest way to add a file or folder to .gitignore without typos is:

  1. Right-click on the file in the project browser and choose "Copy Path" (or use the keyboard shortcut that is displayed there).
  2. Open the .gitignore file in your project, and paste.
  3. Adjust the pasted line so that it is relative to the location of the .gitignore file.

Additional info: There is a .ignore plugin available for IntelliJ which adds a "Add to .gitignore" item to the popup menu when you right-click a file. It works like a charm.

5
  • Actually, using the menu item "Copy Reference" is closer to what you want to copy-paste. (and thank you for the tip) Commented Feb 14, 2015 at 11:45
  • 6
    I've added even better info: There is a plugin that can do this for you.
    – Rolf
    Commented Feb 15, 2015 at 7:47
  • 2
    + for mentioning the plugin
    – mikhail
    Commented Sep 2, 2015 at 15:58
  • 1
    There is a feature request regarding this, please vote if you agree ;)
    – Line
    Commented Feb 15, 2019 at 10:30
  • nice one on the plugin - I was using Tortoise Git to to the same from the windows explorer Commented Jul 22, 2019 at 11:46
51

Intellij had .ignore plugin to support this. https://plugins.jetbrains.com/plugin/7495?pr=idea

After you install the plugin, you right click on the project and select new -> .ignore file -> .gitignore file (Git) enter image description here

Then, select the type of project you have to generate a template and click Generate. enter image description here

12

You can create file .gitignore and then Idea will suggest you install plugin

1
  • Thank you! I was going crazy until I found your post :-)
    – mohsenmadi
    Commented May 14, 2016 at 20:04
9

Here is the screen print showing the options to ignore the file or folder after the installation of the .ignore plugin. The generated file name would be .gitignore enter image description here

2
  • 1
    How is this answer to a 4-year-old question helpful when there are already several working solutions to this question, all of which are a few years old? When posting answers to questions, make sure your answer is helpful and relevant.
    – Joel
    Commented Nov 4, 2018 at 22:08
  • 1
    The screen print is just an addition to the answers listed above. Sure, Thanks! Commented Nov 4, 2018 at 22:30
3

I'm using intelliJ 15 community edition and I'm able to right click a file and select 'add to .gitignore'

1
  • 1
    I'm using version 2022 and the option was not available. I installed the plugin but you can't ignore the file from commit panel Commented May 11, 2022 at 12:48
1

right click on the project create a file with name .ignore, then you can see that file opened.

at the right top of the file you can see install plugins or else you can install using plugins(plugin name - .ignore).

Now when ever you give a right click on the file or project you can see the option call add to .ignore

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.