Claude Code HookGit54 installs

Prevent Direct Push

Prevent direct pushes to protected branches (main, develop). Blocks git push commands targeting main or develop branches to enforce Git Flow workflow. Requires using feature/release/hotfix branches and pull requests instead of direct commits to protected branches.

Install with the Claude Code Templates CLI
$ npx claude-code-templates@latest --hook="git/prevent-direct-push" --yes

Requires Claude Code. The command adds this hook to your project's .claudedirectory — nothing runs on ToolZip's servers.

What's inside this hook

Component source

{

"description": "Prevent direct pushes to protected branches (main, develop). Blocks git push commands targeting main or develop branches to enforce Git Flow workflow. Requires using feature/release/hotfix branches and pull requests instead of direct commits to protected branches.",

"hooks": {

"PreToolUse": [

{

"matcher": "Bash",

"hooks": [

{

"type": "command",

"command": "python3 \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/prevent-direct-push.py"

}

]

}

]

}

}

Type
Hook
Category
Git
Installs
54
Source
GitHub ↗

Related Claude Code Hooks

Catalog data and component content are sourced from the open-source davila7/claude-code-templates project (MIT license). ToolZip curates the listing and writes original descriptions; every component links back to its original source. Claude Code is a product of Anthropic. ToolZip is an independent catalog and is not affiliated with or endorsed by Anthropic.