There are few ways to do it:
.gitignore
.gitignore
is a simple text file which contains list of files which git ignore.
Every file/pattern is written on a single line and the file can be place in your root folder of your project or in any inner folder as well.
When placed in your root folder it can ignore any files/folder i any subfolders.
In case you need to keep certain file or folder you cant add the !
before the phrase.
assume-unchanged
The assume-unchanged
tells git to ignore any local changes made to a given file. In your case same the file with the default or empty values and raise the unchanged flag. git will ignore any changes made so the file will not be added to your repository.

smudge-clean
This hidden feature of git allow you to control which content is added and pulled out from the repository which allow you to control the content of any given file.

git hooks
Read here this full answer on how to do it.
What are some more forceful ways than a .gitignore to keep (force) files out of a repo?