Well, if you’re the build tool that creates that build-folder, then it just means you don’t need to bother your user with adding it to the root gitignore.
One time, I implemented it for basically a repo-specific download cache folder. Ideally, my users don’t need to know of that folder at all.
Or recently, I implemented it for a build tool where my users might not be devs. They might not use Git at all, or not be very adept at it, so I’m glad to not need to document it…

















If you’re an end user, not a build tool, you’d rather want to place that in
.git/info/excludeinside the repo. It’s effectively another gitignore file, which won’t be committed.But if you do need something like this for a build tool, then yeah, you can create a file
/test/.gitignorewith these contents:real-person-first-last.json .gitignoreThen running
git add .just adds/test/fake-person-first-last.json.Both
/test/.gitignoreand/test/real-person-first-last.jsonwould be ignored right away.