mikicomo
V2EX  ›  问与答

Git 使用的一个问题

  •  
  •   mikicomo · May 13, 2017 · 2944 views
    This topic created in 3373 days ago, the information mentioned may be changed or developed.

    Git 追踪的是文件内容的变化。 现在发现这么个问题 我原有一个文件 A.xml 然后 项目经过修改后 重命名为 a.xml 了 并且内容毫无改变。 这个时候 git add . 不能追踪到这个文件的变化,查了下可以通过 git mv 来解决,求问是否有 git add . 这样方便的方式呢?

    16 replies    2017-05-14 19:50:34 +08:00
    zhongdong
        1
    zhongdong  
       May 13, 2017
    git mv A.xml a.xml 本质是执行了 rm a.xml + git add . + git commit
    lcdtyph
        2
    lcdtyph  
       May 13, 2017 via iPhone
    因为你的分区是大小写不敏感的吧?
    mikicomo
        3
    mikicomo  
    OP
       May 13, 2017
    @zhongdong 所以有什么好的办法么?
    @lcdtyph NTFS 的
    Xbluer
        4
    Xbluer  
       May 13, 2017
    @mikicomo 文件名全部小写
    also24
        5
    also24  
       May 13, 2017
    git config core.ignorecase false
    mikicomo
        6
    mikicomo  
    OP
       May 14, 2017
    @also24 感谢!
    cxbig
        7
    cxbig  
       May 14, 2017
    文件系统大小写不敏感造成的问题
    geelaw
        8
    geelaw  
       May 14, 2017 via iPhone
    @cxbig NTFS 是大小写敏感的
    ghostheaven
        9
    ghostheaven  
       May 14, 2017 via Android
    @geelaw ntfs 可以同时存在 a 和 A 两个文件吗?用 a 不能打开文件名是 A 的文件吗?
    mikicomo
        10
    mikicomo  
    OP
       May 14, 2017
    @ghostheaven 大小写敏感的...大家都用 mac 的么?难道 mac 大小写不敏感的?
    geelaw
        11
    geelaw  
       May 14, 2017
    @ghostheaven NTFS 里面当然可以在同一个文件夹下同时存在 a 和 A。

    注意 Win32 API 大小写不敏感不等同于 NTFS 大小写不敏感。

    类比:NTFS 上可以存储叫 con 的文件,不代表你可以用 Win32 API 访问那个叫 con 的文件。

    此外即使只考虑 Win32 这个问题也不是因为 Win32 大小写不敏感导致的,因为 Win32 是 **大小写保持、大小写不敏感** 的,你可以通过 Win32 获取一个文件的准确名字。
    noark9
        12
    noark9  
       May 14, 2017
    @mikicomo 根据建分区的文件系统来的,可区分,可不区分,记忆中好像新机器都是默认不区分大小写的
    ghostheaven
        13
    ghostheaven  
       May 14, 2017 via Android
    @geelaw 不明白。什么情况下可以做到你说的这些呢?
    ghostheaven
        14
    ghostheaven  
       May 14, 2017 via Android
    @geelaw 看了 so 和维基百科,你说的是对的。不过要想使用大小写敏感的 NTFS 不能在 Win32 子系统下,也就是大部分情况下 Windows 应用对待 NTFS 是大小写不敏感的,要么使用 POSIX 子系统调用,要么挂载 NTFS 分区到 Linux 上才可以。
    geelaw
        15
    geelaw  
       May 14, 2017 via iPhone
    @ghostheaven 比如你可以用 WSL 在 NTFS 分区的同一个目录下创建名字只有大小写不同的文件(夹)。

    注意,你这样做会导致用 Win32 API 访问这个文件(夹)产生不必要的麻烦,所以不要用 Win32 访问之,用 WSL,或者用 WSL 清理掉实验现场。
    ghostheaven
        16
    ghostheaven  
       May 14, 2017 via Android
    @geelaw 对,还有 WSL。我原来以为 WSL 是通过一些 NTFS 扩展属性来实现的大小写区分。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2930 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 07:40 · PVG 15:40 · LAX 00:40 · JFK 03:40
    ♥ Do have faith in what you're doing.