Git示例教程 - 有關Git命令無法正確顯示中文路徑的問題

  • 2019 年 11 月 11 日
  • 筆記

相關命令:

#  設置Git讓其在輸出路徑時正確顯示中文  git config --global core.quotePath false    # 如果是Mac用戶,在執行了上述命令後還是不行  # 可以再看下Git的 core.precomposeUnicode 這個參數

情景模擬:

先用下面的命令創建一個測試用的Git倉庫:

# 創建一個空的Git倉庫  mkdir repo  cd repo  git init    # 添加一個文件  touch 中文文件名.txt  

然後執行git status命令:

$ git status  On branch master  Untracked files:    (use "git add <file>..." to include in what will be committed)    "344270255346226207346226207344273266345220215.txt"

‍

由上可見,我們新添加的文件並沒有以中文正確顯示。

下面我們再執行下文章開始時介紹的命令設置一下Git:

$ git config --global core.quotePath false  # 設置Git讓其正確顯示中文路徑    $ git status # 看下設置後的結果  On branch master  Untracked files:    (use "git add <file>..." to include in what will be committed)    中文文件名.txt

看到了吧,在我們設置了Git的 core.quotePath 參數後,中文路徑就可以正常顯示了。

簡單又實用。

Tags: