|
@@ -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` |
|