It may be a requirement of companies, that the master and develop branch contains only code that is always compilable. Therefore we need to ensure that every push, or merge on a master branch results not in breaking the build of the application. This can be achieved with git-hook file that has the Name pre-commit and is copied into .git\hooks directory.
#!/bin/sh branch=$(git rev-parse --abbrev-ref HEAD) if [ "master" != "$branch" ] && [ "develop" != "$branch" ]; then exit 0; fi echo "To commit on a master or develop branch we need to check whether msbuild compiles successful." "C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" /consoleloggerparameters:"ErrorsOnly;PerformanceSummary" status=$? if [ "$status" != "0" ]; then echo "Build failed. If you publish to the $branch branch you should ensure that the solution builds correctly" fi exit $status