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.
Get 5 new use cases every morning. Free, one short email, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
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 [email protected] and we will look at it promptly. Full disclaimer page