跳到主要內容

Git for Windows中文檔名不再亂碼

昨天看到 Getting Started with Git in Visual Studio and Team Foundation Service,也就是說微軟官方將正式支援Git做為Source Control Provider。目前需要安裝Visual Studio 2012 Update 2 CTP 2Visual Studio Tools for Git。所以我也趁機丟掉Subversion,全面投到Git的懷抱。



其實在Git v1.7.10之後,就修改Windows版本儲存時會用UTF-8處理檔名,只是要做些設定,詳情請參考Git for Windows Unicode Support。它和中國高手做的patch是一樣的,在所有平台都會使用UTF-8處理檔名! 從此在各平台都可順利開發共用repository。我個人是不喜歡Git去改我的line ending,詳情看Dealing with line endings

以下節錄Github的說明:

Windows settings

Console font (per user)

The default console font does not support Unicode. Change the console font to a TrueType font such as Lucida Console or Consolas. The setup program can do this automatically, but only for the installing user.

Git settings

These can be set per user (with the --global option) or per repository, the repository settings take precedence.

Disable quoted file names

By default, git will print non-ASCII file names in quoted octal notation, i.e. "\nnn\nnn...". This can be disabled with
 git config [--global] core.quotepath off

Disable commit message transcoding

Previous Git for Windows required to set the i18n.logoutputencoding to your Windows system's default OEM encoding for proper console output of non-ASCII commit messages. This is no longer necessary. Remove this or set it to 'utf-8':
 git config [--global] --unset i18n.logoutputencoding
The i18n.commitencoding setting should also be removed or set to 'utf-8' to support commit messages on the command line (git commit -m "..." from cmd.exe, MSYS bash won't let you enter non-ASCII characters):
 git config [--global] --unset i18n.commitencoding

Disable SVN file name transcoding

If you're using git-svn, reencoding SVN file names is no longer necessary (SVN also stores file names in UTF-8):
 git config [--global] --unset svn.pathnameencoding

Migrating old Git for Windows repositories

This is only relevant if you used non-ASCII file names with non-Unicode Git for Windows versions.
Previous Git for Windows versions stored file names in the default encoding of the originating Windows system, making these repositories incompatible with other Windows language-versions and other Git versions (including Cygwin-Git and JGit / EGit on Windows).
The Unicode-enabled Git for Windows stores file names UTF-8 encoded.

Checking if a repository contains non-ASCII file names

The recodetree check command scans the entire history of a git repository and prints all non-ASCII file names. If the output is empty, no migration is necessary.
Note: the recodetree script doesn't work with quoted characters, disable quoted file names first: git config [--global] core.quotepath off

留言

這個網誌中的熱門文章

自然人憑證讀卡機驅動程式

鳥毅用的是第一代的自然人憑證讀卡機,EZ100PU(後來有同事買EZmini可以讀SIM卡似乎更好),每年報稅時用一次。 本來只是要申請些政府業務,一時之間找不到光碟,沒想到在 驅動程式下載 居然看到Linux和Mac的驅動程式,剩下的就是政府單位的網頁和程式應該改版了吧!!!

在Windows Server設定L2TP over IPSec VPN

簡單地說,macOS Sierra與iOS 10發表後,大家忽然發現Apple不再支援PPTP,所以一定得設定其他的VPN型態。若不要另外裝client,用L2TP是最方便的,SSL VPN雖然好,但若沒有安裝Agent要連線到任一電腦或是非網頁服務還是挺麻煩的。

DBeaver 介面語言

DBeaver是我個人頗常用的一套跨平台Database管理工具,最近升級後發現Windows版本居然變成簡體中文,而且無法切換為英文。