瀏覽代碼

docs(git): 补充 GBK 控制台下中文提交信息乱码的处置

为什么改:
Windows PowerShell 默认按 GBK 解码 UTF-8 输出,git log 里的中文提交信息会显示成
"鍒濆鍖" 这类乱码,容易被误判为提交信息已损坏,从而做出删改历史的危险操作。

改了什么:
- docs/git_workflow.md §0 增加「控制台中文显示」一次性配置:
  [Console]::OutputEncoding = UTF8 + chcp 65001,并给出写入 $PROFILE 的永久做法
- §8 排错表增加对应条目,明确"提交内容本身是对的,不用改历史"
- §5.2 发布检查清单第 7 步:桌面交付包同步改用 robocopy /E,禁止 /MIR
  (/MIR 会删掉交付包里被 .gitignore 的 runs\video_eval\ 证据)

验证:
设置 [Console]::OutputEncoding=UTF8 后 git log --oneline 中文正常显示,
证明库内提交信息(UTF-8)本身正确;robocopy /E 同步后交付包 221 个文件、
runs/ 仅保留 video_eval(2.4 MB)、无 .git 与 __pycache__。

关联:v0.1.0
Administrator 2 周之前
父節點
當前提交
ea49cbcb8b
共有 1 個文件被更改,包括 14 次插入 和 0 次删除
  1. 14 0
      docs/git_workflow.md

+ 14 - 0
docs/git_workflow.md

@@ -42,6 +42,19 @@ git config core.hooksPath .githooks
 > ⚠️ 当前 `user.name` / `user.email` 是占位值(`Administrator` / `administrator@localhost`)。
 > ⚠️ 当前 `user.name` / `user.email` 是占位值(`Administrator` / `administrator@localhost`)。
 > 换成你自己的身份再提交第一次正式修改,历史里的作者信息才不会错乱。
 > 换成你自己的身份再提交第一次正式修改,历史里的作者信息才不会错乱。
 
 
+**控制台中文显示**(务必做一次,否则 `git log` 里的中文提交信息会是 `鍒濆鍖` 这种乱码——
+这只是 PowerShell 按 GBK 解码 UTF-8 输出,**提交内容本身是对的**):
+
+```powershell
+# 当前会话临时生效
+[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
+chcp 65001 | Out-Null
+
+# 永久生效(写进 PowerShell 配置文件,之后每个终端都对)
+if (-not (Test-Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force | Out-Null }
+Add-Content $PROFILE '[Console]::OutputEncoding = [System.Text.Encoding]::UTF8'
+```
+
 ---
 ---
 
 
 ## 1. 五分钟上手
 ## 1. 五分钟上手
@@ -355,6 +368,7 @@ git pull portcv.bundle main                    # 增量拉取
 | --- | --- | --- |
 | --- | --- | --- |
 | `fatal: not a git repository` | 当前目录不在仓库内 | `cd` 到仓库根,或 `git -C <path> ...` |
 | `fatal: not a git repository` | 当前目录不在仓库内 | `cd` 到仓库根,或 `git -C <path> ...` |
 | `无法将 git 项识别为…` | 装完 Git 但终端没重启 | 新开终端;或临时 `$env:Path = 'C:\Program Files\Git\cmd;' + $env:Path` |
 | `无法将 git 项识别为…` | 装完 Git 但终端没重启 | 新开终端;或临时 `$env:Path = 'C:\Program Files\Git\cmd;' + $env:Path` |
+| `git log` 中文提交信息变 `鍒濆鍖` | PowerShell 控制台按 GBK 解码 UTF-8 | `[Console]::OutputEncoding = [Text.Encoding]::UTF8`(见 §0「控制台中文显示」);**提交内容没错,不用改历史** |
 | 提交被 `[pre-commit] 单测失败` 挡住 | 有测试真的红了 | 修测试;确认无关时 `git commit --no-verify` |
 | 提交被 `[pre-commit] 单测失败` 挡住 | 有测试真的红了 | 修测试;确认无关时 `git commit --no-verify` |
 | `push` 被拒(non-fast-forward) | 远端有别人的提交 | `git pull --rebase` 后再 push,**不要** `push -f` 到 `main/develop` |
 | `push` 被拒(non-fast-forward) | 远端有别人的提交 | `git pull --rebase` 后再 push,**不要** `push -f` 到 `main/develop` |
 | 冲突(`<<<<<<<`) | 同一处被两边改 | 手工留一份正确内容 → 删标记 → `git add` → `git commit`;放弃合并用 `git merge --abort` |
 | 冲突(`<<<<<<<`) | 同一处被两边改 | 手工留一份正确内容 → 删标记 → `git add` → `git commit`;放弃合并用 `git merge --abort` |