Live data from Hacker News

Stop Using Git Ignore

eddiejaoude.substack.com

51–60 of 72 posts

Re: Stop Using Git Ignore

#51
post #37

This is bad advice. The repo’s ignore file is there so that other people (without certain domain knowledge) don’t accidentally commit undesirable files, including directories containing sensitive information (which get generated by some tools like Terraform). Use the repo’s ignore, not your own.

I don't think you read the article, there is a video at the end if you prefer. Yes we should use git ignore for the repo specific items, so if the repo has terraform it should ignore generated files - but not desktop tools people use as we all use different dev tools

> Examples of folders included in the git ignore file are generated files like “.next” from NextJS or “test-results” from Playwright. These will be generated for every developer on the project regardless of their OS, IDE etc.

> Yes I am saying this is wrong… (let me know if you agree/disagree below)

I didn't realize that the first paragraph is saying "This is good"; I thought the second paragraph was saying that the first paragraph is bad.

Re: Stop Using Git Ignore

#52

Earlier quoted context omitted.

I don't think you read the article, there is a video at the end if you prefer. Yes we should use git ignore for the repo specific items, so if the repo has terraform it should ignore generated files - but not desktop tools people use as we all use different dev tools

> Examples of folders included in the git ignore file are generated files like “.next” from NextJS or “test-results” from Playwright. These will be generated for every developer on the project regardless of their OS, IDE etc. > Yes I am saying this is wrong… (let me know if you agree/disagree below) I didn't realize that the first paragraph is saying "This is good"; I thought the second paragraph was saying that the…

oh sorry for the confusion! I do think we need both git ignores, but to be used appropriately.

System global .gitignore solves a problem specific to that developer

Repo .gitignore solves a problem for the project (and every developer)

Re: Stop Using Git Ignore

#53
post #28

Let's hope that people who resort to clickbait titles never complain about dark patterns in software, because what they do is analogous, they're tricking me to their advantage.

Sorry you thought it was a trick, I guess I could have extended the title with "...for your personal files"

Thank you for the reply. I believe you have interesting enough material to not need to resort to controversial titles. Keep writing, it'll only get better.

Re: Stop Using Git Ignore

#54
post #53

Earlier quoted context omitted.

Sorry you thought it was a trick, I guess I could have extended the title with "...for your personal files"

Thank you for the reply. I believe you have interesting enough material to not need to resort to controversial titles. Keep writing, it'll only get better.

> I believe you have interesting enough material

thank you, that means a lot to me! I really appreciate the feedback and support

Re: Stop Using Git Ignore

#55
Just a quick mention to remind that .gitignore files can be placed in any folder/subfolder inside a repository, and they will refer to folders inside itself only. The global .gitignore should be used for global rules and root folders, but if you have path with more than one folder on it, you may want to add it to a .gitignore inside that subfolder itself.

Almost mandatory for monorepos too!

Re: Stop Using Git Ignore

#56

Earlier quoted context omitted.

Why is it a problem to have a long .gitignore?

Committing stuff to the repo means work for other people (namely the reviewers). And to find the answer to “why is it a problem that there's a .sublimetext line in the .gitignore” then ask yourself the question “why is it a problem if there's a .sublimetext file committed to the repository”. Why even bothering to add it to the .gitignore when you can just commit the file? Why do you think the second scenario is an is…

The first issue helps to prevent the second issue.

Many projects will need to have a .gitignore to ignore build files or package artifacts. Adding to an existing file is preferable to adding additional files.

Adding IDE level configs can override config files for other developers. The .gitignore does not have this negative impact on others.

Re: Stop Using Git Ignore

#57

Just a quick mention to remind that .gitignore files can be placed in any folder/subfolder inside a repository, and they will refer to folders inside itself only. The global .gitignore should be used for global rules and root folders, but if you have path with more than one folder on it, you may want to add it to a .gitignore inside that subfolder itself. Almost mandatory for monorepos too!

Great point! Thank you for adding that, yes it works for sub folders also, which makes sense especially for mono repos

I really appreciate you adding value to the conversation, thank you!

Re: Stop Using Git Ignore

#58

You'd still need a repository .gitignore, more-so if you're not working in a professional development shop (i.e., SMB/enterprise IT) or open source project. There don't seem to be any downsides to a long .gitignore. Who cares if it is 100 or 1000 lines? Kind of pointless, in my view. I think a user-global .gitignore is fine to have to make sure you don't make mistakes for net-new projects or projects where someone fo…

Yeah, the article's point is also that you need both: > The contents of the repo’s git ignore is for the project only files and folders. Developers can customise their own global git ignore with extra exclusions they need. The two gitignores are for different purposes. The user-specific gitignore (~/.gitignore, or ~/.config/git/ignore) is tailored to the developer's specific workflow and preferred tools, so for examp…

> It doesn't make sense to put editor-specific stuff in the project's .gitignore because the editor or IDE a contributor chooses to use to develop the project is orthogonal to the code in the project.

Why not? What's the harm?

There seems to be zero significant downsides to include editor or operating system-specific patterns in the project .gitignore. A long .gitignore doesn't cause performance issues.

To wit, you'll ultimately have someone without a global .gitignore that will lead to PR cleanup (or worse, direct commits).

The project level .gitignore prevents mistakes by all committers. This is superior to trusting a developer correctly set up their own .gitignore.

I think this is getting to the level of "optimization" because it feels good rather than doing any true good.

Re: Stop Using Git Ignore

#59
post #9

Problems listed in the article: > Everyone uses different operating systems, IDEs and dev tools. How is this related to .gitignore? > This list will only keep growing, it will never end Where's the problem? A random Facebook's repo has its gitignore file weigh 2KB[0]. Is this a problem? > Is the “.gitignore” file competing with the “README.md” for the most updated file in the git repo? I hope not Again, why is this a…

I don't like to rant, I like to have professional discussions. Than you for reading the article and for sharing the FB link with a git ignore example - the contents of the example file is not long because it doesn't have every dev tool possible, so I think you proved my point - so thank you :)

Can you answer the questions?

Re: Stop Using Git Ignore

#60

Disagree. Many projects may want to commit IDE files. Ignoring them globally is simply wrong.

oh wow, really! why? sounds like a horrible project, imagine those git conflicts can you elaborate on why they would want to commit IDE generated files? I have only seen this in legacy projects what happens if people want to use different IDEs?

> imagine those git conflicts

Not an issue

> why they would want to commit IDE generated files

You added the word generated.

Many Windows-oriented projects a Visual Studio .sln file. This is great! You can open the sln, build, and run. It “just works”. Very nice. I wish more projects did this.

> what happens if people want to use different IDEs?

That’s fine. Nothing stopping it.

Post reply on HN