mikicomo
V2EX  ›  问与答

Git 使用的一个问题

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

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

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

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

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