My personal experience is that the build
folder should be ignored in git by default. I've come across situations where one would want to add the build
folder to git (and perhaps an additional README.txt in it) to let users know where to build the project. However, that is deviating from the general premise that anything automatically generated should never be part of a repository.
So why am I asking, then? Well, the GitHub's own gitignore repository did not include the build/
line in any one of the .gitignore
files I combined together, not even in the CMake.gitignore
itself. That to me is a reason to doubt my own judgement.
Should build/
be part of the CMake gitignore? Is it not there because of the assumption that users are always doing true out-of-source builds? To my experience, that is very false. In fact, I haven't seen a single guide recommend a true out-of-source build once. Not even the Microsoft's own VS Code CMake Tools extension does true out-of-source builds.
I assume it's safe to add build/
to my root .gitignore
file. But what are the reasons to not do it?