Resolving Chinese Character Encoding Issues in Git on Windows
This article explains why Git on Windows often displays garbled Chinese characters in tools like Git Bash, CMD, PowerShell, and IDEs, and provides step‑by‑step solutions—including Git config changes and environment variable adjustments—to enforce UTF‑8 encoding and eliminate the problem.
When using Git on Windows, users often encounter garbled Chinese characters in various tools such as Git Bash, CMD, PowerShell, Git GUI, Visual Studio, VS Code, and IDEs, especially with Chinese file paths and commit messages.
Symptoms:
Running git status shows unreadable paths and filenames, and git log displays corrupted commit messages, as illustrated in the screenshots.
Causes:
1. Windows defaults to GB2312 for file names and content, while Git uses UTF‑8. 2. Git’s log output uses the less pager, which is not compatible with Windows encoding. 3. Different terminal tools handle environment variables differently.
Solution: unify UTF‑8 encoding across all components.
Modify Gitconfig
You can set the configuration at the system level (affects all users) or at the global level (affects the current user). In enterprise or server environments, system‑level settings are recommended.
Run the following commands (use --system instead of --global with elevated privileges if needed):
$ git config --global core.quotepath false # Fix encoding of file paths in git status
$ git config --global gui.encoding utf-8 # GUI Git client encoding
$ git config --global i18n.commit.encoding utf-8 # Commit message encoding
$ git config --global i18n.logoutputencoding utf-8 # Log output encodingFor more details about gitconfig, refer to the FAQ #2.
Modify Environment Variables
Because Git for Windows may be invoked from different terminals, set environment variables accordingly. If you only use one terminal, adjust only that one.
1. For Git Bash, edit C:\Program Files\Git\etc\profile and add: export LESSCHARSET=utf-8 Editing this file also requires elevated permissions.
3. For other Windows terminals such as PowerShell, CMD, and Cmder, set the appropriate environment variables as shown in the screenshot.
Result After Fix
Screenshots demonstrate that Git Bash, CMD, Cmder, and PowerShell now correctly display Chinese characters.
Related articles:
Git Enterprise Developer Tutorial
Microsoft R&D Cloud Suite VSTS Login China
Markdown/reST Documentation DevOps Pipeline
7 Useful Git GUI Clients
Using SSH to Connect to TFS/VSTS Git Repositories
GitHub + VSTS Bidirectional Sync
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
DevOps
Share premium content and events on trends, applications, and practices in development efficiency, AI and related technologies. The IDCF International DevOps Coach Federation trains end‑to‑end development‑efficiency talent, linking high‑performance organizations and individuals to achieve excellence.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
