When git encounters Chinese garbled characters

Git has a strange problem. When Chinese appears in the directory or file name, when git status is executed, a string of unicode codes will be returned. This unicode code cannot be read and must be resolved.

git status shows unicode/garbled characters

$ git status
untracked file :
    "\346\265\213\350\257\225/"

Solution:

$ git config --global core.quotepath false
$ git status
untracked file :
    测试/文件.md

To solve the puzzle:

The role of core.quotepath is to control whether the path is encoded and displayed. When the characters in the path are greater than 0x80, if set to true, escape display; set to false, do not escape.

Garbled characters in git commit log

There are more problems on the windows platform than on linux.

$ git config --global gui.encoding utf-8

$ git config --global i18n.commitEncoding utf-8

$ git config --global gui.logOutputEncoding utf-8

Basically all of the above can be solved.

Windows platform displays garbled characters

Right-click gitbash and select "Options"-"text". Set the locale below to zh_CN, and the Character Set to UTF-8.
It is strongly recommended to use UTF-8 for all, and use less GBK.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324935030&siteId=291194637