DEV Community

YCM Jason
YCM Jason

Posted on • Edited on

4

How to create gitignore file with predefined templates?

For people who create project frequently, one thing that is very annoying would be creating the gitignore file. The same set of files, but why write it again. Even copying from other directory is a waste of effort. This is why I have created gitignorer.

To install this program, simply run:

> npm i -g gitignorer
Enter fullscreen mode Exit fullscreen mode

This program allow you to create the gitignore file with a predefined set of files. For example:

> gitignore init node
# created by gitignorer
# profile used: node
*.sw*
.DS_Store
node_modules
npm-debug.log*
Enter fullscreen mode Exit fullscreen mode

Isn’t this great?

All the profiles are defined at ~/.gitignore.profiles.js. The definition is simple and intuitive. Here is one of the examples:

/*** ~/.gitignore.profiles.js ***/
var common = [
  '*.sw*',
  '.DS_Store'
];

var node = [
  'node_modules',
];

var java = [
  'url: https://raw.githubusercontent.com/github/gitignore/master/Java.gitignore',
  '.object2'
];

module.exports = {
  default: common,
  node: [...common, ...node],
  java: [...common, ...java],
  awesome: [...commone, ...node, ...java],
};
Enter fullscreen mode Exit fullscreen mode

Neon image

Serverless Postgres in 300ms (!)

10 free databases with autoscaling, scale-to-zero, and read replicas. Start building without infrastructure headaches. No credit card needed.

Try for Free →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay