How to add files/folders to .gitignore in IntelliJ IDEA?

GitIntellij IdeaGitignore

Git Problem Overview


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?

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

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

Solution 3 - Git

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

Solution 4 - Git

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

Solution 5 - Git

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

Solution 6 - Git

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpiotrekView Question on Stackoverflow
Solution 1 - GitRolfView Answer on Stackoverflow
Solution 2 - GitbiniamView Answer on Stackoverflow
Solution 3 - GitnanotexnikView Answer on Stackoverflow
Solution 4 - GitTechPassionateView Answer on Stackoverflow
Solution 5 - Gitmancini0View Answer on Stackoverflow
Solution 6 - GitPavanView Answer on Stackoverflow