protect-push

Block direct git pushes to main branches and enforce Pull Requests.

Updated May 15, 2026
One-click install
npx skills add https://github.com/heyu-ai/yibi-stack --skill protect-push
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: protect-push
Source: https://github.com/heyu-ai/yibi-stack/tree/main/plugins/bash-hygiene/skills/protect-push
Command: npx skills add https://github.com/heyu-ai/yibi-stack --skill protect-push

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill prevents direct pushes to the main branch, ensuring that all changes go through the Pull Request (PR) workflow, maintaining code quality and collaboration.

Core Features & Use Cases

  • Prevent Direct Pushes: Blocks direct pushes to the main branch if the branch is tracking origin/main or origin/master.
  • Branch Tracking Check: Checks the branch tracking configuration before executing any git push.
  • User-Friendly Warnings: Provides clear instructions on how to resolve the issue, such as creating a feature branch or adjusting the branch tracking.

Quick Start

Run the 'protect-push' skill to install the hook in your project.

Frequently Asked Questions about protect-push

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

FAQPage Schema
How do I prevent direct git pushes to the main branch?

To prevent direct git pushes to the main branch, you can use a PreToolUse hook to intercept push commands and block them if the branch tracks origin/main or origin/master. This enforces a Pull Request workflow for all code changes.

What is the best way to enforce a PR workflow in git repositories?

The best way to enforce a PR workflow in git repositories is by checking the branch tracking configuration before executing git push. Blocking direct pushes to the main branch ensures all changes go through Pull Requests, maintaining code quality and collaboration.

How does branch tracking check work for push protection?

Branch tracking check for push protection works by verifying if the current branch is tracking origin/main or origin/master before allowing a git push. If it is, the direct push is blocked and clear instructions are provided to create a feature branch instead.

Can I use git worktree and still block direct pushes to main?

Yes, you can use git worktree and still block direct pushes to main. This push protection applies to all projects using EnterWorktree or git worktree add, requiring only proper git configuration for branch tracking and a PreToolUse hook for command interception.

Why are my direct pushes to origin/main being blocked?

Your direct pushes to origin/main are being blocked because a push protection mechanism is actively enforcing a Pull Request workflow. It checks branch tracking configuration and halts git push operations tracking origin/main or origin/master, directing you to use a feature branch.