chore(git): main分支保护(pre-commit hook禁止直接提交main) + go.md补分支策略

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Qiufeng
2026-06-15 20:30:28 +08:00
co-authored by Claude Opus 4.8
parent 0dd513db6e
commit 65e64cc717
2 changed files with 24 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
# main 分支保护:禁止直接在 main 上提交(main 是受保护的稳定线)。
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [ "$branch" = "main" ]; then
echo "=================================================================="
echo " 拒绝提交:main 是受保护的稳定线,不允许直接在上面改/提交。"
echo " 请切到开发分支再提交: git checkout dev"
echo " 确需向 main 落稳定快照: git commit --no-verify (并随后打 tag)"
echo "=================================================================="
exit 1
fi
exit 0