Plugins Tips & Tricks

Touring Plugins – GitIgnore

I always have a .gitignore file in my Dropbox folder that I copy over for new projects, knowing that any subsequent update to the copy isn’t always synced with the original. Of course, it’s not always necessary either, but it’s something that’s always bugged me.

Recently I ran across a plugin for IntelliJ IDEA (and family) that solves my issue with ignore files.

It’s called GitIgnore Support and as its name suggests it provides support for .gitignore files, but it goes way beyond what you’d imagine at first. Let’s take a look.

Generating an ignore file from templates

The plugin connects to GitHub’s template repository for file patterns and displays a list of templates from which we can create an initial ignore file.

new-file

If using IntelliJ IDEA or family, there’s a specific template named JetBrains which is most suited. We can get to this by creating a new file (Cmd+N on OSX 10.5) and selecting the .gitignore (it actually suggests to create one for new projects).

generate

The templates have a series of file and directory masks commented out which we can fine-tuning based on our needs.

Adding existing items from project

At any time, if we want to ignore a file or folder that is in the project view, we can right click and select Add to .gitignore

add-to-git

Syntax highlighting and inspections

In addition to generating and keeping the ignore file for us, the plugin also provides syntax highlighting and what’s more interesting, inspections, allowing for duplicate detection or entries that we actually think are doing something but in reality are not, something I’ve had headaches with occasionally.

inspections

For every inspection, and in fact every entry, it offers an Intention to remove the entry

error

Summary

The plugin is definitely useful for both existing projects that we’d want to update or clean up the ignore file, and even more interesting for new projects, since as mentioned previously, it prompts us to create the corresponding ignore file, something I personally often forget to do until that first staging.

It is open source and the code is available on GitHub

image description

Discover more