簡體   English   中英

從 Mercurial 遷移后,Git 在 Windows 11 上無法正確識別帶有變音符號的文件

[英]Git does not recognise files with umlauts correctly on Windows 11 after migration from Mercurial

我嘗試在 Git Bash 中通過以下方式從 Mercurial 存儲庫遷移到 Windows 11 上的 Git:

MINGW64$ ls
hg-repo/ git-repo/
MINGW64$ cd git-repo
MINGW64$ git init
MINGW64$ ~/fast-export/hg-fast-export.sh -r ../hg-repo/ --force -A ../hg-repo/authors.txt -M main

遷移成功,需要以下內容

MINGW64$ git checkout main

這應該會導致存儲庫沒有任何更改。 但是我得到的是以下內容:

MINGW64$ git status
On branch main
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
    deleted:    Folder1/grünes-Ding.png
Untracked files:
(use "git add <file>..." to include in what will be committed)
    Änderungen/
    Folder1/grünes-Ding.png

所以它看起來像“Folder1/grünes-Ding.png”被刪除然后重新添加。 如果我嘗試恢復文件夾,我會得到以下信息。

MINGW64$ git restore Folder1/grünes-Ding.png
error: pathspec 'Folder1/grünes-Ding.png' did not match any file(s) known to git

我認為在這種情況下 Git 不理解“Folder1/grünes-Ding.png”,因為 ü 在 Git 中以另一種方式表示,正如我在 git-bash 中看到的那樣。 “Änderungen/”也應該在存儲庫中。 因為如果我在工作目錄中刪除它,它的所有文件都會顯示為“已刪除”更改。 如果我隨后嘗試恢復這些文件,我會得到相同的錯誤類型。 此文件夾中的文件不包含變音符號。

我的問題是:如何告訴 Git 處理帶有變音符號的文件夾和文件?

到目前為止,我發現的關於變音符號的唯一一件事就是在日志或提交消息中正確顯示它們。 但這不是這里的問題。

我的 Git 配置如下所示:

MINGW64$ git config -l
diff.astextplain.textconv=astextplain
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=input
core.fscache=true
core.symlinks=false
pull.rebase=false
init.defaultbranch=main
difftool.sourcetree.cmd=''
mergetool.sourcetree.cmd=''
mergetool.sourcetree.trustexitcode=true
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.quotepath=false
core.fsmonitor=true
i18n.logoutputencoding=UTF-8
MINGW64$ locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_ALL=

我試了一下 hg-fast-export 的選項,最終找到了解決方案。

hg-fast-export 有兩個處理編碼的選項: -e--fe -e在 Mercurial 中定義提交消息和作者姓名等的編碼以將其轉換為 UTF-8 並且--fe定義文件名的編碼。

我為文件名嘗試了不同的編碼,發現latin1對我有用。 但首先,我錯誤地使用了-fe而不是--fe 但是-fe結果是-f-e而不是--fe 所以要注意這一點! 如果您使用-e ,選項--fe也會自動設置為-e的值,這會導致提交消息的編碼錯誤。

最后,遷移工作是這樣的

MINGW64$ ls
hg-repo/ git-repo/
MINGW64$ cd git-repo
MINGW64$ git init
MINGW64$ ~/fast-export/hg-fast-export.sh -r ../hg-repo/ --force -A ../hg-repo/authors.txt -M main --fe latin1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM