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:
- Right-click on the file in the project browser and choose "Copy Path" (or use the keyboard shortcut that is displayed there).
- Open the .gitignore file in your project, and paste.
- 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.