更改.gitattributes会立即更改索引(在Windows上)

时间:2019-01-07 12:22:40

标签: git

TL; DR浏览存储库时,对.gitattributes的更改会立即更改索引(不运行git命令)。为什么?到底发生了什么?

我在git行结尾处遇到问题,git diff显示了随机代码文件上已更改的行结尾。最终,我能够将其跟踪到gitattributes行:

*.cs  text  diff=csharp

排除text部分可以解决此问题:

*.cs  diff=csharp

奇怪的是,使用git bash进入存储库根目录时,更改立即发生。即使我将*.cs text添加回.gitattributes文件,代码文件也不会再显示更改。

已采取的步骤

  1. 运行git status

    $ git status
    On branch master
    Your branch is up to date with 'origin/master'.
    
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)
    
            modified:   File1.cs
            modified:   File2.cs
    
    no changes added to commit (use "git add" and/or "git commit -a")
    
  2. 此时更改.git属性文件(请参见上文)

  3. 重新运行git status

    $ git status
    On branch master
    Your branch is up to date with 'origin/master'.
    
    nothing to commit, working tree clean
    

更新:将索引与git ls-files --debug

进行比较

浏览存储库后,大多数文件的索引都会立即发生以下更改(旧大小为0,新大小因文件而异)

之前

Form1.cs
  ctime: 1524665651:594691900
  mtime: 1524665651:596697700
  dev: 0        ino: 0
  uid: 0        gid: 0
  size: 0       flags: 0

之后

Form1.cs
  ctime: 1524665651:594691900
  mtime: 1524665651:596697700
  dev: 0        ino: 0
  uid: 0        gid: 0
  size: 5817    flags: 0

0 个答案:

没有答案