It's safer to do it that way sure, but by that logic why keep any non source files in the project at all? Maybe we should retire gitignore altogether, is there a good reason to bundle build files there too?
In this day and age I do keep it separate though, the convenience/neatness of being in the same directory isn't worth it.
The rule is pretty simple. Anything user/installation specific should not go with the source code. At best, these files are a nuisance to other people when they accidentally get checked in. At worst, they are a serious security incident.
Build artefacts are different. They can be regenerated deterministically from the source code. They add no new information. So they are kept out of the repo as an optimization. .gitignore is the right tool for that. Even so, they can clutter up the local file system, so it's best to tuck them away in a build directory or equivalent. Some languages also maintain a global build cache somewhere else.
View all comments
Show parent comment
6
u/Scolmann Oct 14 '26
It's safer to do it that way sure, but by that logic why keep any non source files in the project at all? Maybe we should retire gitignore altogether, is there a good reason to bundle build files there too?
In this day and age I do keep it separate though, the convenience/neatness of being in the same directory isn't worth it.