Generate .gitignore files with Bash function06 Sep 2014
No more copy/pasting lines from old
Every Git repo needs a
.gitignore file, these often vary from project to project and creating them can be a tedious process.
This process used to, at least for me, involve copy/pasting from previous projects only to end up with a new project-specific Frankenstein-like file. Around a year ago I stumbled upon the site gitignore.io which makes it super simple to generate
.gitignore files without resorting to copy/pasting from old projects.
The only problem was that when I start new projects I’ll usually be in my Terminal or editor of choice, and I don’t want to switch contexts by going to a website to generate the file.
I haven’t written much Bash besides a couple of small scripts here and there, but I thought I could add one little feature to the original gist by kqr. The ability to append existing
Here is the full slightly edited function:1
The code should be fairly self explanatory and straight-forward to understand. To use the function in your Bash shell: