Search⌘ K
AI Features

Additional Information on Hooks

Explore how Git hooks function as automation tools that do not travel with code commits. Understand differences between client-side and server-side hooks, including pre-commit and pre-receive scripts, and how they help enforce team rules like requiring ticket IDs in commits. This lesson helps you implement hooks to maintain consistent workflows in collaborative Git projects.

Are hooks part of Git content?

A question you may be asking yourself at this point is whether the hooks are part of the code or not. You wouldn’t have seen any mention of the hooks in your commits; so does it move with the repository as you commit and push or not?

An easy way to check is to look at the remote bare repository directly.

1	cd ../git_origin
2	ls hooks
Terminal 1
Terminal
Loading...

Examining the output of the above will show that the pre-commit script is not present on the bare origin remote. It does not move with the code nor is it considered part of the code committed.

This presents a problem if you are working in a team. If the whole team decides that they do not want any mention of politics in their commits, then they will have to remember to add the hook to their local clone. This isn’t ...