You can add a pre-commit hook.
You can version in your git repo a hook script (say pre-commit.sh) at the root of your project and include the installation instructions in your README/documentation to encourage all developers use it.
Installation is nothing more than:
ln -s ../../pre-commit.sh .git/hooks/pre-commit
As the article "Tips for using a git pre-commit hook", you need, in that hook, to ensure that code that isn't part of the prospective commit isn't tested within your pre-commit script:
# pre-commit.sh
git stash -q --keep-index
# Test prospective commit
# call format, stylecop...
git stash pop -q