{
 "schema_version": 1,
 "generated": "2026-10-20",
 "id": "enroute-sh-enroute--block-force-pushes-to-main",
 "repo": "enroute-sh/enroute",
 "repo_url": "https://github.com/enroute-sh/enroute",
 "repo_slug": "enroute-sh-enroute",
 "title": "Block force pushes to main with a pre-receive hook",
 "page_title": "How to block force pushes to main with a pre-receive hook with Enroute",
 "summary": "Write a pre-receive hook that rejects ref updates which would overwrite main.",
 "who": "A team lead who hosts code on Enroute and needs to stop anyone from rewriting the main branch.",
 "problem": "Force pushes to main can erase commits, and most Git setups do not stop them without extra tooling.",
 "outcome": "A pre-receive hook that refuses non-fast-forward updates to main and lets other branches through.",
 "steps": [
  "Read the pre-receive section in docs/reference/hooks.md to see the payload of each call.",
  "Write a pre-receive handler in your app that rejects updates to refs/heads/main that are not fast-forward.",
  "Enable the pre-receive hook in your deployment using the hook setup described in docs/README.md. (inferred, check the README)",
  "Force push a test branch to main with `git push --force http://127.0.0.1:8080/hello.git main` and confirm the push is rejected. (inferred, check the README)"
 ],
 "agent_prompt": "In the enroute-sh/enroute repository, read docs/reference/hooks.md and write a pre-receive hook in <app-dir> that rejects non-fast-forward updates to main. Expected output: a hook handler that returns a rejection for those updates. Verify by force pushing a test commit to main and confirming it is rejected.",
 "agents": [
  "any"
 ],
 "difficulty": "Advanced",
 "time": "60 minutes",
 "basis": "readme",
 "caveat": "The README does not show the exact configuration to enable a hook, so check docs/operate/ and docs/reference/hooks.md before relying on this step.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "rust",
 "requirements": [
  "Linux or macOS on Apple silicon, or Docker to run the published image",
  "git installed on your machine",
  "A terminal and, for hooks, a language you can write a small server in"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.8,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/enroute-sh-enroute/block-force-pushes-to-main/",
 "md": "https://dedupedai.com/use-cases/enroute-sh-enroute/block-force-pushes-to-main/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/enroute-sh-enroute--block-force-pushes-to-main.json",
 "api_version": "v1"
}
