TL; DR浏览存储库时,对.gitattributes的更改会立即更改索引(不运行git命令)。为什么?到底发生了什么?
我在git行结尾处遇到问题,git diff
显示了随机代码文件上已更改的行结尾。最终,我能够将其跟踪到gitattributes行:
*.cs text diff=csharp
排除text
部分可以解决此问题:
*.cs diff=csharp
奇怪的是,使用git bash进入存储库根目录时,更改立即发生。即使我将*.cs text
添加回.gitattributes文件,代码文件也不会再显示更改。
运行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")
此时更改.git属性文件(请参见上文)
重新运行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