Live data from Hacker News

Stop Using Git Ignore

eddiejaoude.substack.com

61–70 of 72 posts

Re: Stop Using Git Ignore

#61
It would be very inconvenient to try to synchronize global gitignore settings to all my computers and development environments. When .gitignore files are part of the project, they are automatically distributed everywhere where they are needed.

Re: Stop Using Git Ignore

#62

Earlier quoted context omitted.

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…

Because a dev's IDE project file can differ between every other dev, so committing it doesn't make sense. On the other hand, adding it to the .gitignore solves the problem of having differing config files.

But why is a “config file” (which is usually no more than a few dozen bytes) a problem? If you agree to add the name of the file in your .gitignore, why do you even bother to ignore it in the first place. It pollutes the .gitignore file as much as it pollutes the root directory…

Re: Stop Using Git Ignore

#63

Earlier quoted context omitted.

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.

But adding it to the developer's machine is preferable to both!

Re: Stop Using Git Ignore

#64

Earlier quoted context omitted.

I'm not sure about that. We had a new hire once add a ton of .DS_Store files because we forgot to ignore it at the repo level and they didn't have a global ignore set up. I don't see the point of committing files that have no purpose in the repo, especially these ones, that could change between users age potentially polluting the diffs. We added it to the ignore list and removed the files

Or you could have taught them how to add the ignore file on their computer so they won't be making the same mistake in any other repo or other projects… And you could have used the opportunity to teach them about using a version control altogether and how it they aren't supposed to just throw git commit -am "fix stuff" at every problem! The fact that they committed the .DS_store files shows there's a much deeper prob…

We don't care if this problem is "hidden under the rug". We didn't even consider it to be a problem. One line added to the gitignore and no future hires will have the ability to do this. Why is adding lines to a gitignore a problem? We've looked at it maybe a handful of times since it was initialised

Re: Stop Using Git Ignore

#65

Earlier quoted context omitted.

I'm not sure about that. We had a new hire once add a ton of .DS_Store files because we forgot to ignore it at the repo level and they didn't have a global ignore set up. I don't see the point of committing files that have no purpose in the repo, especially these ones, that could change between users age potentially polluting the diffs. We added it to the ignore list and removed the files

I don't think that's a good argument. An inexperienced developer can inadvertently do a lot of damage in infinitely many ways, and your example is just one of them. I don't think it's a good principle to structure a code base to protect inexperienced coders from themselves, which is always going to be a losing battle. This may have been a missed opportunity for a teachable moment: - The new hire most likely used `git…

We can do both those things and also take away their ability to add unwanted files which is exactly what we did. Why even allow things like this to happen when a single line to a gitignore solves it forever? The reason we saw those .DS_Store files in the first place was during PR review

Re: Stop Using Git Ignore

#66

Earlier quoted context omitted.

Or you could have taught them how to add the ignore file on their computer so they won't be making the same mistake in any other repo or other projects… And you could have used the opportunity to teach them about using a version control altogether and how it they aren't supposed to just throw git commit -am "fix stuff" at every problem! The fact that they committed the .DS_store files shows there's a much deeper prob…

We don't care if this problem is "hidden under the rug". We didn't even consider it to be a problem. One line added to the gitignore and no future hires will have the ability to do this. Why is adding lines to a gitignore a problem? We've looked at it maybe a handful of times since it was initialised

You'll think about this discussion the next time it happens again on a nez git repo you've just created.

Why is adding a .gitignore line a problem you ask, but then someone could ask why is committing those .DS_store files a problem in the first place… In both cases the problem is that you are adding garbage unrelated to the project.

Re: Stop Using Git Ignore

#67
post #59

Earlier quoted context omitted.

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?

>> Everyone uses different operating systems, IDEs and dev tools. > How is this related to .gitignore?

Exactly! I explained in the article (and video) people fill the repo git ignore with all their personal tools that generate files, for example .DS_Store, .Idea etc. This should go in their personal global git ignore

>> 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?

Have a look at some other projects. I explained in the article (and video) the file can be pages long with every possible combination and will only keep growing as new dev tools come out

>> 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 bad thing?

As I explained in the article, it becomes a lot of work for the maintainers, to review, check for duplicate entries etc

Re: Stop Using Git Ignore

#68
post #61

It would be very inconvenient to try to synchronize global gitignore settings to all my computers and development environments. When .gitignore files are part of the project, they are automatically distributed everywhere where they are needed.

> they are automatically distributed everywhere where they are needed

for you and your tools, but what about everyone else?

Look at using dotfiles to sync your computer's config to multiple computers, it is a great tool

Re: Stop Using Git Ignore

#69
post #61

It would be very inconvenient to try to synchronize global gitignore settings to all my computers and development environments. When .gitignore files are part of the project, they are automatically distributed everywhere where they are needed.

> they are automatically distributed everywhere where they are needed for you and your tools, but what about everyone else? Look at using dotfiles to sync your computer's config to multiple computers, it is a great tool

Other people working on the project add their ignored files to the same .gitignore. No problem.

Re: Stop Using Git Ignore

#70
post #69

Earlier quoted context omitted.

> they are automatically distributed everywhere where they are needed for you and your tools, but what about everyone else? Look at using dotfiles to sync your computer's config to multiple computers, it is a great tool

Other people working on the project add their ignored files to the same .gitignore. No problem.

I don't understand why people make an issue of that. Just add everything that needs to be ignored to the .gitignore, as long as it makes sense to someone. If I use XYZ-Obscure-Unknown-Editor, just let me add `.xyz-obscure-unknown-editor/` to the .gitignore. It literally has no negative impact on anyone.

There's no reason to gatekeep what goes to the .gitignore

Post reply on HN