Git can customize hooks that can be executed under certain circumstances, divided into client-side hooks and server-side hooks. Client-side hooks are triggered by operation, such as Commit,merge, server-side hooks are triggered by network actions, such as pushed commits.
So where does the hook go?
Under the. git/hooks/folder. When you init a warehouse, there are some examples of hooks below, ending with. Sample.
Then when the hook is executed, git pre-defines the trigger timing:
Clientside Hooks:
1 Pre-commit, when performing a commit action, the hook is executed first, you can use this hook to do some checks, such as code style check, or run the test first.
2 prepare-commit-msg, this hook is triggered when a commit is required to enter a message, so you can use this hook to customize your default message information.
3 Commit-msg, when the user input a commit message is triggered, you can use this hook to verify the message information, such as whether it complies with the provisions, there is no CR.
4 Post-commit, when commit is triggered, you can send notification with this hook.
5 Pre-rebase, Rebase will be triggered before, you can use this hook to reject all the already push commits for rebase operation.
6 Post-merge, this hook will be triggered when the merge succeeds.
7 Pre-push, when push, remote refs is updated, but is triggered before all objects are transmitted.
8 PRE-AUTO-GC, which is triggered before Git GC--auto executes. It's nice to do some verification or backup before garbage collection.
ServerSide Hooks:
1 pre-receive, which is executed before the push action is received.
2 Update is also executed before the push action is received, but it is possible to be executed multiple times, each branch once.
3 Post-receive, when the push action is completed, it will be triggered, you can use this hook to push notification, such as e-mail, notify the continuous build server and so on.
Remember that all hooks are supposed to be executed.
chmod u+x Your_hook
So you can use shell scripts, Perl,python and so on to write hooks.
Original: http://blog.csdn.net/hongchangfirst/article/details/46693237
Author: Hongchangfirst
Hongchangfirst's homepage: http://blog.csdn.net/hongchangfirst
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Three minutes to teach you to learn git (17)-Hooks