DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to block force pushes to main with a pre-receive hook with Enroute

Write a pre-receive hook that rejects ref updates which would overwrite main.

Short answer: Read the pre-receive section in docs/reference/hooks.md to see the payload of each call; then 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. All steps.

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

  1. Read the pre-receive section in docs/reference/hooks.md to see the payload of each call.
  2. Write a pre-receive handler in your app that rejects updates to refs/heads/main that are not fast-forward.
  3. Enable the pre-receive hook in your deployment using the hook setup described in docs/README.md. (inferred, check the README)
  4. 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)

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

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer