# 跨平台一键启用 Git Hooks 配置 (Windows PowerShell) Write-Host "⚙️ 正在配置 Git 协作规范..." -ForegroundColor Cyan # 1. 配置 Hooks 路径 git config core.hooksPath .githooks # 2. 关闭当前仓库的 autocrlf,防止误转 CRLF git config core.autocrlf false # 3. 开启符号链接支持 (Symlinks) git config core.symlinks true if ($LASTEXITCODE -eq 0) { Write-Host "✅ Git Hooks 与 Windows 规范配置成功!" -ForegroundColor Green Write-Host "📌 保护规则已生效:" -ForegroundColor Yellow Write-Host " - 禁止在 main 分支直接开发与 commit" Write-Host " - 强制分支名称全小写(杜绝 Windows 大小写冲突)" Write-Host " - 拦截超过 15MB 的单文件提交" Write-Host " - 拦截包含 Windows 非法字符与保留设备名的文件" Write-Host " - 禁止直接向远程 main 分支 push 代码(强制 GitHub PR 合并)" Write-Host " - 换行符保持 LF (core.autocrlf = false)" Write-Host " - 启用软链接支持 (core.symlinks = true)" } else { Write-Host "❌ 配置失败,请检查 git 是否已安装并加入 PATH。" -ForegroundColor Red exit 1 }