Git hooks ਉਹ scripts ਹਨ ਜੋ Git ਸਵੈਚਲਿਤ ਤਰੀਕੇ ਨਾਲ Git workflow ਵਿੱਚ ਕਰਤਬ ਪੁਆਇੰਟਾਂ ਤੇ ਚਲਦੇ ਹਨ (commits, pushes, merges, ਆਦਿ ਤੋਂ ਪਹਿਲਾਂ/ਬਾਅਦ ਵਿੱਚ)। ਉਹ ਸਵੈਚਲਿਤਤਾ ਨੂੰ ਸਮਰਥ ਬਣਾਉਂਦੇ ਹਨ — معایر ਨੂੰ ਲਾਗੂ ਕਰਨਾ, ਜਾਂਚਾਂ ਚਲਾਉਨਾ, ਅਤੇ ਕਰਿਆਵਾਂ ਨੂੰ ਟਰਿਗਰ ਕਰਨਾ — ਅਤੇ ਕੋਡ ਦੀ ਗੁਣਵੱਤਾ ਅਤੇ CI integration ਲਈ ਵਿਆਪਕ ਤੌਰ ਤੇ ਵਰਤੇ ਜਾਂਦੇ ਹਨ।
Hooks ਕੀ ਹਨ
Hooks are executable scripts in .git/hooks/ (or managed by tools) that Git runs on EVENTS:
CLIENT-SIDE (local):
pre-commit → before a commit is created (lint, format, run quick tests)
commit-msg → validate/format the commit message
pre-push → before pushing (run tests, prevent pushing broken code)
post-merge/checkout → after merge/checkout (e.g. reinstall dependencies)
SERVER-SIDE (on the remote):
pre-receive / update → enforce policies on push (reject bad pushes)
post-receive → trigger deployment/CI/notifications after a push
