Unable to add files with name containing tilde, '~' followed by a number

后端 未结 1 874
陌清茗
陌清茗 2020-12-10 06:14

The folder consists of files with filenames like abc~1, 123~1, a1d2~3.

When I do git add --all it says,



        
相关标签:
1条回答
  • 2020-12-10 06:46

    This is the result of a change that was made to msys Git in December 2014.

    On Windows' default filesystems, FAT and NTFS, DOS-style 8.3 file names are supported for backwards compatibility. That means that there are multiple ways to reference the same file. For example, the file credential-cache--daemon.c can also be accessed via CREDEN~1.C (unless another 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 on Windows, and while at it, we also exclude other file names incompatible with Windows' file systems (e.g. NUL, CON, etc).

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

    To disable this behaviour, you can run:

    git config core.protectNTFS false
    

    However, since the new behaviour is there to protect you, I’d recommend changing it back after having added your files:

    git config core.protectNTFS true
    

    Only disable this protection when you need to add files with tildes in the name or check out branches containing such filenames.

    In general, I’d recommend avoiding such filenames if working in a Windows environment.

    0 讨论(0)
提交回复
热议问题