I am trying to exclude a file (db/irrelevant.php) from a Git diff. I have tried putting a file in the db subdirectory called .gitattributes>
It's very simple, you can exclude what you want using standard unix commands, those commands are available under git bash even under windows environment. Below example shows how to exclude diff for pom.xml files, first check diff to master only for filenames, then using 'grep -v' exclude files which you don't want and then run again diff to master with prepapred list:
git diff master `git diff --name-only master | grep -v pom.xml`