Skip to content

Comments

chore: Add git workflow enforcement with pre-push hook#66

Merged
pfrederiksen merged 1 commit intomainfrom
chore/git-workflow-enforcement
Jan 12, 2026
Merged

chore: Add git workflow enforcement with pre-push hook#66
pfrederiksen merged 1 commit intomainfrom
chore/git-workflow-enforcement

Conversation

@pfrederiksen
Copy link
Owner

Problem

Direct pushes to main were happening repeatedly, violating the project's branch → PR → merge workflow.

Solution

Two-layer protection:

  1. Git pre-push hook (.git/hooks/pre-push)

    • Blocks direct pushes to main or master
    • Shows clear error message with correct workflow
    • Installed automatically with scripts/setup-git-hooks.sh
  2. CLAUDE.md update

    • Added prominent "🚫 GIT WORKFLOW - CRITICAL" section at top
    • Includes step-by-step workflow instructions
    • Shows common mistakes to avoid
    • Documents hook installation and recovery procedures

Changes

  • Created .git/hooks/pre-push to block direct main pushes
  • Created scripts/setup-git-hooks.sh for easy hook installation
  • Updated CLAUDE.md with prominent workflow section
  • Tested: Hook successfully blocks push to main ✅

Testing

# Hook blocks direct push to main:
$ git push origin main
❌ ERROR: Direct push to 'main' is not allowed!

Benefits

  • Prevents accidental direct pushes to main
  • Enforces PR workflow automatically
  • Clear error messages guide correct behavior
  • Easy to install on new clones with setup script

🤖 Generated with Claude Code

@claude
Copy link

claude bot commented Jan 12, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@pfrederiksen pfrederiksen merged commit 1c95002 into main Jan 12, 2026
4 checks passed
@pfrederiksen pfrederiksen deleted the chore/git-workflow-enforcement branch January 12, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant