git: デフォルトブランチっぽいやつはcommitを不許可
置き場所の例: ~/.config/git/hooks/pre-commit
code:shell
# hooks.protectDefaultBranchで保護する・しないの決定
# 設定方法
# git config --global hooks.protectDefaultBranch true|false
exit 0
fi
branch="$(git rev-parse --abbrev-ref HEAD)"
if echo "$branch" | grep -E "^(main|master|develop)$"; then
echo "❌ 保護されたブランチ '$branch' へのコミットは禁止"
echo "この設定は $0 にあります"
exit 1
fi
exit 0