People on my dev team keep on pushing build specific files (node_modules and others) onto our repos despite these files being in a .gitignore file, presumably with git
It's not an easy problem to solve as git is distributed.
Server side filters like post commit hooks (or commit filter plugins if you are using Stash) allow the users to get themselves into a mess which is not great.
The client pre-commit hook is cleaner because it prevents the users from polluting their repo but this solution isn't bullet proof.
You could approach the problem from another perspective and move build artefacts and intermediate files out of you repository directory.