In order to extend the functionality of git, I recommend you the concept of hooks. They can be put into your Fetch/Pull/Deploy workflow at any desired level.
The most important thing to keep in mind is that they're just working locally. If you want to provide them on your repository provider (like github.com), you can make use of so-named web hooks.