no-force-push-main

Prevents force-pushing to main and guides safe force-with-lease use on feature branches.

Updated Mar 10, 2026
One-click install
npx skills add https://github.com/jasoncrawford/brunel --skill no-force-push-main-jasoncrawford
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: no-force-push-main
Source: https://github.com/jasoncrawford/brunel/tree/main/.claude-plugin/skills/no-force-push-main
Command: npx skills add https://github.com/jasoncrawford/brunel --skill no-force-push-main-jasoncrawford

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Force-pushing to main rewrites shared history, breaks other contributors' references to commits, and is a leading cause of lost work in collaborative repositories. This Skill intervenes before a destructive git push --force or --force-with-lease targets main or any shared protected branch. ## Core Features & Use Cases - Blocks force-push to main: Stops any attempt to run git push --force or --force-with-lease against main or other protected shared branches. - Distinguishes branch contexts: Explains why force-pushing is acceptable on feature branches after a rebase but never on main. - Promotes --force-with-lease: Directs users to the safer --force-with-lease flag, which fails if someone else pushed to the branch since the last fetch. - Use Case: After rebasing a feature branch, an agent or developer is about to run git push --force; this Skill redirects them to git push --force-with-lease and confirms the target is not main. ## Quick Start Before I push my rebased branch, check whether force-pushing is safe and tell me the correct git push command to use.

Frequently Asked Questions about no-force-push-main

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I push after rebasing a feature branch in git?▼

After rebasing a feature branch, use git push --force-with-lease because the rebase rewrote commit SHAs and a plain push will be rejected. The --force-with-lease flag fails safely if someone else pushed to your branch since your last fetch.

What is the difference between git push --force and --force-with-lease?▼

git push --force overwrites the remote branch unconditionally, while --force-with-lease checks that the remote ref matches your last fetch and fails if someone else pushed. Always prefer --force-with-lease on feature branches.

Why is force-pushing to main dangerous?▼

Force-pushing to main rewrites shared history, destroying other people's and other agents' references to commits. It causes divergence requiring manual recovery and is the leading cause of lost work in collaborative repositories.

When is it acceptable to force-push in git?▼

Force-pushing is acceptable only on feature branches you own, typically after a rebase, and only with --force-with-lease. It is never acceptable on main or any shared protected branch under any circumstances.

What should I do instead of force-pushing to main?▼

Instead of force-pushing to main, merge or rebase your changes through a normal pull request workflow so history is preserved. If main history is broken, coordinate recovery with your team rather than rewriting shared commits.