docs: 记录中文 commit message 乱码修复经验(提交历史重写为 2c90205/4b3ea03/b11bea1)

This commit is contained in:
2026-08-23 11:39:23 +08:00
parent b11bea1962
commit 8df2f002d2
4 changed files with 12 additions and 1 deletions
+7
View File
@@ -201,3 +201,10 @@
- **新增根目录 `开发进度存档`(无扩展名)**:作为跨会话上下文恢复入口,含目录结构/快速启动/打包手册(含所有坑)/代码结构地图/功能清单/待办/Git 信息/踩坑实录表。
- MEMORY.md 更新:顶部加「换环境先读 `开发进度存档`」指引;文档三件套说明;打包章节更新(128.9MB、build/icon.ico、SafeDelete 坑)。
- 目的:用户重装 CodeBuddy/换文件夹路径后,新会话读 `开发进度存档` 即可省积分快速恢复上下文。
## 2026-08-23 修复中文 commit message 双编码乱码
- **现象**`git log` 提交信息显示乱码(如 `椤圭洰闇€姹傚崌绾?`),经字节级验证(cmd 重定向 + node 读 hex)确认为**存储层乱码**PowerShell/cmd 把中文 `-m` 参数按 GBK 编码传给 git,git 按 UTF-8 存储 → 双编码。
- **修复**Node 脚本(`fix-msgs.js`,用完已删)用 `git cat-file commit` 读原对象 → 保留 headertree/parent/author/committer/时间戳)→ 仅替换 message → `git hash-object -t commit -w --stdin` 重建 → `git update-ref`。新 hash`2c90205`init/`4b3ea03`build/`b11bea1`docs)。已 `git push --force-with-lease` 强推(用户授权),`69d592b...b11bea1 (forced update)`,远程一致、工作区干净。
- **以后约定**:提交信息用 `git commit -F <utf8消息文件>`write_to_file 生成的 UTF-8 文件),**禁用 `git commit -m "中文"`**。
- **执行环境备注**execute_command 实际走 cmd`2>$null` 会被当作重定向生成 `$null` 文件(需手动删);`;` 不分割 cmd 命令;`[Console]::OutputEncoding=UTF8` 对 git 输出无效,验证用 `git log > file` 后 read_file 工具读。