Create Fat .gitignore in Intellij

Rather than create my .gitignore file by hand or copy from a previous project, I do not prefer this method. Is there a quicker way to generate the .gitignore file with many of the things I don’t want to be tracked by Git to be included in it.

ANSWER

Intellij IDEA

Plugin: https://plugins.jetbrains.com/plugin/7495–ignore/

Add that to your Intellij IDEA app. There is a button in that page to automatically download and install this plugin. Make sure the Intellij app is running before hitting that button.

Or you could simply download, then install manually. Select the Versions tab in the plugin page. Choose the version you want to download. Find the zipped file in your “downloads” folder.

To install manually, head over to: Settings > Plugins > (gear icon) > Install Plugin from Disk

The gear icon might be different with other versions of IntelliJ.

The plugin should be activated already, not needing an app restart.

Eclipse

For Eclipse, I’m not sure of a plugin that has pre-defined lists. I can right click on a folder/file and add to .gitignore (Team > Ignore), is what I did before. Haven’t tried an Eclipse Marketplace search.

Visual Studio Code (VS Code)

Click extension then type in “gitignore” in the search box. Look for the extension by CodeZombie. Versions as of this writing is 0.7.0.

To use, do the following:

Start command palette (with Ctrl+Shift+P or F1) and start typing Add gitignore

Other

Another way is to go to gitignore.io OR github.com/github/gitignore and get a generated .gitignore template from there. Search/select the application, OS you want. Then copy/download the generated templates.

How to make IntelliJ check and create SerialVersionUID

When the class implements Serializable I want the serialVersionUID field to be auto-created by IntelliJ IDE. This feature comes in automatically in Eclipse. But the former does not.

How do I make IntelliJ create the field or warn me that it is not defined in the class yet?

ANSWER

It is not turned on by default in IntelliJ. Can be easily done by going to the following:

File > Settings > Editor > Inspections > Java > Serialization Issues

Then find and select – Serializable class without ‘serialVersionUID’ – by checking on the box to the right of it.

Similarly, you can search for it once in File > Settings. Keyword for search can be – ‘serialVersionUID’ – without the quotes.

The path or location of this feature on IntelliJ may vary. It should be the same on Linux and Windows for versions 2019 and 2020.

This will only throw a warning. It does not magically create the field in all those classes that implements Serializable straight away. But then IntelliJ will help you create it, like any other decent IDE out there. Go to the class name declaration, you may find that it is subtly highlighted in yellow to hint that there is a user action that can be done. Hover then click on the option – Add ‘serialVersionUID’ field – and you will get the desired result like this one:

private static final long serialVersionUID = 6265605531073886420L;