Ignore the Blueprint

A blog about programming, life and everything.

Simplify Your Project Setup with Gitignore.io


The Tool

When starting a new project, there's always a chore to be done: creating the .gitignore file.

I've been using Gitignore.io for a long time. It's a great tool that allows you to generate a .gitignore file for your project based on the OS, IDE and programming language you're using.

You can always visit the website in your browser and manually type the keywords to generate the file. But there's a better way: using the command line.

CLI

Since the generated file is based on keywords, we can use the curl command to generate the file.

curl -sLw "https://www.toptal.com/developers/gitignore/api/macos,visualstudiocode" >> .gitignore

You can also write a function in your .bashrc or .zshrc file to make it easier to use.

function gi() {
    curl -sLw "\n" https://www.toptal.com/developers/gitignore/api/$@ ;
}

Now you can use the gi command to generate the .gitignore file.

gi macos,visualstudiocode

Global Gitignore

But we are lazy, so the less typing the better. You can create a global .gitignore_global file in your home directory that will be used for all your projects.

gi macos,visualstudiocode >> ~/.gitignore_global

git will automatically use this file. If not, you can add it manually.

git config --global core.excludesfile ~/.gitignore_global