Introduction
In order to work efficiently in a corporate environment, there are certain prerequisites, or rules, regarding any code that is produced. It should be able to compile and pass specific sets of unit tests. There should also be certain documentation in the commit messages, such as references to a bug fix ID or an instance. Most of these rules can be automated using scripts. But why not put these rules into the process? In this chapter, you will see some examples of how to transfer data from one location to a commit message before you see the message. You will also learn how you can verify whether you are pushing your code to the right location. Finally, you will see how you can add scripts to Git.
A hook in Git is a script that will be triggered on events, such as pushing, committing, or rebasing. If these scripts exit with a non-zero value, it is probably best to cancel the current Git operation. You can find these hook scripts in the .git/hooks
folder in any Git clone. If they...