Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean .gitignore files #30

Open
coderbyheart opened this issue Jan 3, 2020 · 2 comments
Open

Clean .gitignore files #30

coderbyheart opened this issue Jan 3, 2020 · 2 comments

Comments

@coderbyheart
Copy link
Owner

coderbyheart commented Jan 3, 2020

The controversial tweet for this: https://coderbyheart.com/twitter/status/1212980450861420544

A .gitignore in a project should only cover artifacts caused by the contained source code, not those caused by the personal choice of editor and/or environment of a developer. Use a global git ignore file for that.

Yes, you can solve it also with a well maintained .gitignore file that covers everything in all projects but this can get quite extensive to cover all cases.

I consider it noise if entries are in the .gitignore that have no relation to the specific project: I want a clean .gitignore file.

Maintaining a global .gitignore file for your personal setup also has the advantage that it affects all existing and future projects on your machine, thus eliminating the possibility of accidentally committing those files. Otherwise you would need to remember to add your IDE files to EVERY projects .gitignore.

Additionally, changes to the .gitignore of a project are not free: they trigger CI runs, releases, reviews. Having people constantly add their favourite rules creates noise. I don't want that.

Having a huge catch-all .gitignore is no solution either, it will only cover known files. Additions trigger noise.

Adding files to a git repository is a deliberate action, if developers add files that do not belong to a feature or change they need to be better educated about it.
If this is done, an accident-preventing-gitignore is no longer needed.

Good example

dist/
node_modules/

Bad example

.idea
.vscode
.DS_Store

Tip

Have a local folder to put your crap in which won't get accidentally committed

@coderbyheart coderbyheart changed the title Only project-specific entries in .gitignore Clean .gitignore files Jan 3, 2020
coderbyheart added a commit to homeferences/website that referenced this issue Mar 18, 2020
Only project-specific files should go in the .gitignore:
See coderbyheart/first-principles#30
@haraball
Copy link

Sounds like a .gitinclude might make more sense. When you git -a a file, it's included. Otherwise it'll never show up in git.

@coderbyheart
Copy link
Owner Author

Well, if you encourage developers to use git add -A (add all untracked files), then that could be a solution:

*.*
!*.ext

Will tell git to ignore all files except those with the .ext extension.

I think however that this is already a built-in feature of git: it only tracks what you tell it to track.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants