{
  "id": 22154258,
  "title": "How to Configure Git Hooks: Stop Pushing Secrets and Broken Commits",
  "url": "https://urgent.news/2026/11/27/how-to-configure-git-hooks-stop-pushing-secrets-and-broken-commits",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-27T11:30:00.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/mango7777/how-to-configure-git-hooks-stop-pushing-secrets-and-broken-commits-2a0g"
  },
  "original_language": "en",
  "account": "Git hooks are scripts that run at specific points during Git's workflow, such as during commit, push, or receive operations. They can help prevent mistakes like pushing secrets or broken commits. However, by default, Git hooks are local, meaning each developer must install them manually, which often leads to inconsistencies across the team. To address this, modern approaches use a version-controlled directory called .githooks/ for hooks, ensuring consistency across all machines. Git hooks come in various types, including client-side and server-side hooks, each running at different stages of the Git workflow. While client-side hooks can be bypassed, server-side hooks enforce policies that cannot be bypassed. Teams should use both client and server-side hooks to achieve the best protection. Setting up Git hooks involves prerequisites like Git 2.36+ and having a secret scanner. The pre-commit framework, written in Python, is a popular tool for managing hooks declaratively. It allows teams to define their hooks in a .pre-commit-config.yaml file and install them using a single command, ensuring all developers have the same hooks installed. After installation, Git hooks run automatically during the commit process, helping to catch and prevent mistakes like pushing secrets or broken commits.",
  "summary": "The first time I watched a teammate push an AWS access key to a public GitHub repo, I learned two things. First, GitHub's secret scanning alerts are fast - we got the email in 47 seconds. Second, the team had a pre-commit hook that should have caught it. It just wasn't installed on her laptop, because hooks don't sync with the repo, and nobody had set up a way to make them sync. The four hours we…",
  "key_points": [
    "Git hooks are scripts that run at specific points in Git's workflow",
    "Default Git hooks are local, leading to inconsistencies across teams",
    "Use both client-side and server-side hooks for best protection"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}