piotrek piotrek - 2 months ago 29x
Git Question

how to add files/folders to gitignore in intellij GUI?

I try to switch from eclipse to intellij. I have a project that uses git and I want to quickly add files to .gitignore. in eclipse i has right click on a file/dir and option 'add to .gitignore'. is there anything like this in idea or do i have to edit the file manually?


EDIT: Intellij has a plugin as of now (2016): https://plugins.jetbrains.com/plugin/7495?pr=idea. Look at the answer below by biniam_Ethiopia

As far as I can see 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 ".gitignore" 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.

To install the plugin, go to "Settings -> Plugins", click on "Browse repositories..." and search for ".ignore".