I had shared a precommit here which help you check your code before your commit. If you want to deploy it on test machine even production machine, you may need this.
You just change
I suggest change
dev instead of master if you deploy to test machine.
Here is the code.
hooks/ of your remote repo. Set executable to it with
chmod u+x hooks/post-receive. Just type
git push remote dev and enjoy it!