记录规划页提交参数经验

This commit is contained in:
2026-07-22 19:18:21 +08:00
parent a3240d2323
commit e7877be77d
+8
View File
@@ -280,3 +280,11 @@
- 处理方式:临时脚本执行前用 UTF-8 BOM 重写一次,或改用 `Get-Content -Encoding UTF8` 读取后执行;复杂脚本仍放在 `D:\codex\tmp`。
- 以后避免:包含中文或非 ASCII 的临时 PowerShell 脚本,不要直接 `powershell -File` 执行无 BOM 文件;先显式保证编码。
- 验证方式:执行前后检查脚本中的中文数组/字符串能被正确解析,并确认生成物存在且非零字节。
## 2026-07-22 `git commit --only` 参数顺序不能把 `-m` 放在路径后
- 问题:为了只提交本次规划页三文件,执行 `git commit --only -- <paths> -m "..."` 时,Git 把 `-m` 和提交信息都当成 pathspec,提交失败。
- 原因:`--` 后面的参数全部按路径解释,`-m` 这类提交选项必须放在 `--` 和路径列表之前。
- 处理方式:改用 `git commit -m "..." --only -- <paths>`,只把指定文件的工作区内容纳入提交。
- 以后避免:有用户已有 staged 改动时,如果需要提交本次文件,先确认 `git diff --cached --name-only`,再用 `git commit -m "中文信息" --only -- <paths>`;不要把提交选项写在 pathspec 后。
- 验证方式:提交后用 `git show --name-only --oneline HEAD` 确认只包含目标文件,并用 `git diff --cached --name-only` 确认用户原有 staged 文件仍保留。