解决 Powershell 里 Git 输出中文乱码的问题
问题
使用 git 命令时,有时候会遇到这样的乱码:
1 | PS C:\Projects\metac\pcl-edu-platform> git reset --hard 842d1bba HEAD is now at 842d1bb chore: 浣跨敤鏇寸ǔ瀹氱殑鏂瑰紡杩涜鐢熶骇閮ㄧ讲 |
解决
先配置一下 git:
1 | git config --global core.quotepath false |
然后启动 powershell,然后在里面输入以下命令打开 Powershell 的配置文件:
1 | notepad $PROFILE |
然后写入:
1 | # Force UTF-8 for native command output, e.g. Git for Windows |
保存后,关闭当前 PowerShell / Windows Terminal 标签页,重新打开。
然后验证:
1 | chcp |
期望输出可能是:
1 | Active code page: 65001 |
- 标题: 解决 Powershell 里 Git 输出中文乱码的问题
- 作者: 三葉Leaves
- 创建于 : 2026-05-07 00:00:00
- 更新于 : 2026-05-07 11:27:27
- 链接: https://blog.oksanye.com/9382f6706e13/
- 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论