Who it is forA team lead who hosts code on Enroute and needs to stop anyone from rewriting the main branch.
The problemForce pushes to main can erase commits, and most Git setups do not stop them without extra tooling.
The outcomeA pre-receive hook that refuses non-fast-forward updates to main and lets other branches through.
What you need first
- 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
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 mainand confirm the push is rejected. (inferred, check the README)
Prompt for your agent
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.
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.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for enroute-sh/enroute and "Block force pushes to main with a pre-receive hook"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer