DEV Community

loading...
Cover image for I created a .gitignore command-line generator !

I created a .gitignore command-line generator !

christopherkade profile image Christopher Kade ・1 min read

If you're like me, you pretty much Google "gitignore templates" each time you start a new project from scratch. That's at least 15 seconds you'll never get back, so I made a command-line tool for that 🤷‍♂️

Introducing gitignore-it, here's how it works:

gitignoreit

Feel free to install it globally, it's super lightweight and will save you a few seconds.

If you want to contribute, you can always create new .gitignore files that will be usable right away.

And if I've saved you those vital few seconds at the beginning of your project, feel free to give it a little ⭐️ Github Link

Discussion

pic
Editor guide
Collapse
oyetoket profile image
Oyetoke Toby

I made something similar which I am using locally. I called it Gnit, it git init and also ask for the .gitignore folders to add and also select base on language. It is written in python, I can share with anyone tho.

Collapse
_imkaka profile image
Anil Khatri

Great, will love to see your code.

Collapse
vlasales profile image
Vlastimil Pospichal

Create an alias to Git to write:

git ignore -h          # help
git ignore -a "*.tmp"  # add row
git ignore -e          # edit .gitignore
git ignore -l          # list of templates
git ignore             # show .gitignore
git ignore Node        # select template

... etc. I have an alias git exclude too.

Collapse
nickytonline profile image
Nick Taylor (he/him)

Just curious how this differs from the gitignore package that consumes GitHub's awesome gitignore repository.

GitHub logo github / gitignore

A collection of useful .gitignore templates

A collection of .gitignore templates

This is GitHub’s collection of .gitignore file templates We use this list to populate the .gitignore template choosers available in the GitHub.com interface when creating new repositories and files.

For more information about how .gitignore files work, and how to use them the following resources are a great place to start:

Folder structure

We support a collection of templates, organized in this way:

  • the root folder contains templates in common use, to help people get started with popular programming languages and technologies. These define a meaningful set of rules to help get started, and ensure you are not committing unimportant files into your repository
  • Global contains templates for various editors, tools and operating systems that can be used in different situations. It is…
Collapse
christopherkade profile image
Christopher Kade Author

Hey, thanks for sharing this package, I did not know of its existance. I did know of Github's list though as I've used it.

At the moment, the only difference is that I prompt the user for a language. Eventually, I'd like to generate the gitignore automatically based on the user's environment.

Collapse
codenamejason profile image
Jaxcoder

That would be great adding the .gitignore during scaffolding automatically based on the environment.

Collapse
charrismatic profile image
Matt Harris

I actually just published a similar kind of utility for generating "grepignore" files and some other nice things for searching. I was thinking pretty much the same thing you wrote while I was making it.

I can see the gitignore being pretty useful though, I spent way longer than I should have earlier today trying to figure out the right string to get rid of a bunch of junk from a commit.

Collapse
codenamejason profile image
Jaxcoder

I am going to definitely check this out for I have been starting a lot more applications using Visual Studio Code and command line and having nice tools to help be just a bit more productive adds up over time to save time.

Collapse
ben profile image
Collapse
geraldokandonga profile image
Geraldo Kandonga

Man, you have got a solution to my problem

How does it work? i tried installing it on my machine and i run gitignore but i am getting gitignore command not found

Collapse
christopherkade profile image
Christopher Kade Author

Did you install it globally?

npm i -g gitignore-it

Collapse
geraldokandonga profile image
Geraldo Kandonga

Yes, I followed the instructions on npm, I am using windows

Collapse
codenamejason profile image
Jaxcoder

I had same problem, command not found and I restarted VS Code and my cmd's.

Collapse
ybalrid profile image
Arthur Brainville

This is nice. Many times in the past I copy-pasted the content of one of the sample gitingore for various programming languages that are maintained on GitHub here github.com/github/gitignore

Looks like you've made a nice time saving tool right there! 😄

Collapse
jetaimefrc profile image
Harry Trần

Can I multiple select? Like as Node, VSCode, MacOs... ?

Collapse
christopherkade profile image
Christopher Kade Author

It could be an option in the future, for now it's one gitignore at a time

Collapse
dirtyf profile image
Frank Taillandier

gitignore zsh plugin allows you to specify multiple gitignore:

gi node ruby >> .gitignore

github.com/robbyrussell/oh-my-zsh/...

Collapse
paulchiu profile image
paulchiu

A service I use often for the same purpose is: gitignore.io/

Collapse
christopherkade profile image
Christopher Kade Author

Yeah that could be the next step, I could parse the user's package.json (or equivalent file) and generate a gitignore based on that :)

Collapse
talk2sohail profile image
Sohail

Super cool.
I was willing to learn about in near future but I came across this.

Will help a lot.
Thanks.

Collapse
adriengibrat profile image
Adrien Gibrat

Use it once to generate a global .gitignore in your home directory with everything related to your local env (OS, IDE) and only add specific rules in your repo can avoid .gitignore file full of cruft.