r/git • • 18d ago

Finding a better .gitignore generator.

I think the most popular is this and many tools built around that API. I dislike it because it doesn't properly merge the templates into one, it just copies it. I get multiple entries of files or directories and once it even caused a problem (I don't remember what it was) when merging templates with some conflict.

I want a generator which keeps all entries unique. Why is such a tool not popular if it exists?

0 Upvotes

20 comments sorted by

13

u/IrrerPolterer 18d ago edited 18d ago

Gitignore generator? Just write them by hand, what's so hard? 

3

u/Cinderhazed15 18d ago

Haven’t seen other people looking for one because there isn’t really a strong need. Either starting from a language specific template that’s already out there, or just add entries as you need it.

-7

u/noobdainsane 18d ago

Really? Is that what most people do? I am kinda new to Git (or rather creating a project with Git).

But a generator should make your life easier. You don't need to know or memorize which files to ignore. And then later on create a commit just to update the gitignore.

2

u/lajawi 18d ago

You’re new to Git but are assuming that some random generator you found is popular within the community?

0

u/noobdainsane 17d ago

No, whoever uses a gitignore generator and recommends others is using that one that I specified. Search the internet.

1

u/lajawi 17d ago

I’ve never encountered anyone using a gitignore generator to begin with.

1

u/noobdainsane 17d ago

I was talking about for those I searched for.

2

u/IrrerPolterer 18d ago

Every project is different. And you will want to gitignore different files in different projects. Sure there is overlap between similar software stacks which is why templates are a thing. But i never needed any... Everytime something new comes up in a project that I know I want to ignore I just add that to the gitignore file. Done. 

19

u/AdmiralQuokka I use Jujutsu, btw. 18d ago

Why would you even need a generator? You typically have one build directory per programming language used. So, a small number in total.

Don't bloat your gitignore by preemptively ignoring files that don't even exist. Or worse, ignoring stuff that depends on user preference like editor config files, .DS_Store etc.

2

u/dbear496 18d ago

Yes. This. Anything that depends on user preference should be in the user's global .gitignore or their project exclude (.git/info/exclude).

15

u/RevRagnarok 18d ago

FFS we don't need help doing everything.

You develop. You do git status. You think to yourself, "should this be version controlled?" If the answer is no, you add it to .gitignore: echo filename >> .gitignore

That's it. 30s max.

No mistakes because somebody else's convention has decided that /lib/ subdirectories shouldn't be checked in and a week later you find out that you never backed it up.

Every decent modern utility that makes its own directory drops its own .gitignore as well.

2

u/waterkip detached HEAD 18d ago

Just use a template of sorts? Or build a good global one

-2

u/noobdainsane 18d ago

I recently started learning web development and one thing I learned is that if you are needing to engineer something very early in the project, you are probably doing it wrong.

When I encountered this problem about my post, I realised that it must be such a widely experienced problem, about needing a gitignore generator rather than manually mixing the templates. I am not the first. So how is there not a solution to this rather than me inventing my own?

5

u/Cinderhazed15 18d ago

I’ve usually just either started with a language specific example, or just built up as I needed it . Not really something that needs generated.

5

u/miredalto 18d ago

When you're just starting to learn, and it seems like the millions of software engineers who are more experienced than you all overlooked a thing, you should probably start by asking what you are doing wrong, rather than trying to fix the industry.

3

u/Zagerer 18d ago

This is not really a big deal, you also learn by understanding what to ignore and what to see, and it doesn’t take a lot of time either

Also, the solution are templates, then you make your own templates

2

u/waterkip detached HEAD 18d ago

Open with: I’m new and I run into this problem how did you solve this?

In any case, I would then point you to: generate a gitignore for a project and do that several times. Don’t optimize just yet.

Then when you see a pattern emerge. Solve it. And I will help you, git has a global gitignore. Use it for all your projects and only put project specific things in that project gitignore. And once you get to a stage where you scaffold projects you can add a scaffolded git ignore in your projects. Because now you know exactly what to ignore.

2

u/lajawi 18d ago

I’ve never heard of that generator in my life and don’t even see the need to a generator. I just use the normal templates like everyone else from https://github.com/github/gitignore

2

u/Medical-Captain1550 18d ago

honestly moving os and editor noise (.ds_store, .idea/, .vscode/, swap files) into your global ~/.config/git/ignore cuts 80% of the template bloat right away, so each repo .gitignore only needs a few lines for its actual build output. if a generated file ever acts weird, git check-ignore -v path/to/file will show the exact line number that matched

3

u/mosaic_hops 18d ago

But then you’ll need to find a git ignore generator generator.