繁体   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