# Git Hooks: Scripts Git Runs for You

A Git hook is a script Git runs at a set moment: a pre-commit hook in .git/hooks runs before every commit, and when it ends with an exit code other than 0, the commit is stopped, so test.sh and ShellCheck run without anyone having to remember them.

![Cheat sheet for the lesson Git Hooks: Scripts Git Runs for You: A Git hook is a script Git runs at a set moment: a pre-commit hook in .git/hooks runs before every commit, and when it ends with an exit code other than 0, the commit is stopped, so test.sh and ShellCheck run without anyone having to…](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/eb17d17133d942d3beedd9ed822ba7aa.webp)

- Category: Bash
- Level: Freelancer
- Tags: exit-code, git-hook, linux, pre-commit-hook, shellcheck, unix
- Updated: November 10, 2026

Source: https://www.ask-codey.com/cheat-sheets/bash-git-hooks-cheat-sheet
