Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   gitfaq    ( 7 )

Часто задаваемые вопросы об использовании Git (Frequently asked questions about using Git)

Хуки (Hooks)

How do I use hooks to prevent users from making certain changes?
           The only safe place to make these changes is on the remote
           repository (i.e., the Git server), usually in the pre-receive
           hook or in a continuous integration (CI) system. These are
           the locations in which policy can be enforced effectively.

It's common to try to use pre-commit hooks (or, for commit messages, commit-msg hooks) to check these things, which is great if you're working as a solo developer and want the tooling to help you. However, using hooks on a developer machine is not effective as a policy control because a user can bypass these hooks with --no-verify without being noticed (among various other ways). Git assumes that the user is in control of their local repositories and doesn't try to prevent this or tattle on the user.

In addition, some advanced users find pre-commit hooks to be an impediment to workflows that use temporary commits to stage work in progress or that create fixup commits, so it's better to push these kinds of checks to the server anyway.