gpt4 book ai didi

git - 无法添加名称包含波浪号、 '~' 后跟数字的文件

转载 作者:太空狗 更新时间:2023-10-29 12:45:19 25 4
gpt4 key购买 nike

该文件夹由文件名类似 abc~1123~1a1d2~3 的文件组成。

当我执行 git add --all 时,它说,

$ git add --all
error: Invalid path 'abc~1.png'
error: unable to add abc~1.png to index
fatal: adding files failed

我进行了反复试验,发现仅当波浪符号后跟数字时此错误仍然存​​在。

如果该文件夹是第一次被 git 跟踪,则其他文件也不会被 Git 跟踪。

$ git clean --dry-run
Would remove Rest.png
Would remove abc~1.png

请帮助我如何解决这个问题。

最佳答案

这是对 msys Git in December 2014 所做更改的结果.

On Windows' default filesystems, FAT and NTFS, DOS-style 8.3 file names aresupported for backwards compatibility. That means that there are multipleways to reference the same file. For example, the filecredential-cache--daemon.c can also be accessed via CREDEN~1.C (unlessanother file has already been mapped to that so-called "short name", i.e.the exact short name is unpredictable).

Since this mapping is unpredictable, we need to disallow such file names onWindows, and while at it, we also exclude other file names incompatible withWindows' file systems (e.g. NUL, CON, etc).

We use the core.protectNTFS guard introduced in the previous commit to makesure that we prevent such file names only when appropriate.

要禁用此行为,您可以运行:

git config core.protectNTFS false

但是,既然新行为是为了保护你,我建议添加文件后将其改回:

git config core.protectNTFS true

仅当您需要在命名或检查包含此类文件名的分支。

一般来说,如果工作在Windows 环境。

关于git - 无法添加名称包含波浪号、 '~' 后跟数字的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29294910/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com