Skip to content

Instantly share code, notes, and snippets.

@mnvr
Created July 12, 2025 05:33
Show Gist options
  • Save mnvr/82264144455abe1bde1ac8f0e2ae8182 to your computer and use it in GitHub Desktop.
Save mnvr/82264144455abe1bde1ac8f0e2ae8182 to your computer and use it in GitHub Desktop.
A pre commit hook that prevents committing on main
#!/bin/sh
if test "$(git rev-parse --abbrev-ref HEAD)" = "main"
then
echo "error: cannot commit to main"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment