Git diff 疯了?
我正在尝试了解我的本地 Git 存储库发生了什么情况。
- 我编辑一个文件。
- Git 报告文件中的所有内容都已更改(我只更改了一行行)
- 起初我认为“一定是换行符问题”,但事实并非如此。我在 TortoiseGit 中做了一个 diff,一切看起来都很好。我与 Netbeans(git 插件)进行了比较,一切似乎都很好。
- 我重置、备份文件、修改它,git 再次报告一切都已更改。
- 我在 Total Commander 中进行了二进制比较,除了我更改的单行之外,这些文件没有差异。
- 我再次进行硬重置。 Git 告诉我它已成功完成。 Git status still 表示我的文件已更改。我比较了这个东西,没有区别 - bug git 说有。
我尝试过使用 git bash 和 gui,得到相同的结果(我在 Windows 上)。任何线索,这里发生了什么?
I'm trying to figure out what's going on with my local Git repo.
- I edit a file.
- Git reports everything has changed in the file (I only changed one line)
- At first I think "must be a newline problem", but it's not. I do a diff in TortoiseGit, everything looks fine. I do a diff with Netbeans (git plugin), everything seems fine.
- I do a reset, backup the file, modify it, git again reports everything has changed.
- I do a binary compare in Total Commander, the files have no differences except for the single line I changed.
- I do a hard reset again. Git tells me it was done successfully. Git status still says my file has changed. I diff the thing and there are no differences - bug git says there are.
I've tried using both git bash and gui, with same results (I'm on Windows). Any clues, what's going on here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Windows 使用不同的换行符,当您在 Windows 环境中编辑文件时,您使用这些设置,然后当 Git 查看它时,它无法识别换行符。您可以尝试使用 vi 将文件格式设置为 unix,这会将所有换行字符转换为 unix 样式: set ff=unix
希望有帮助
Windows uses different line feed characters, when you edit the file in the Windows environment you use those settings, then when Git looks at it it doesn't recognize the line feed. You can try using vi to set the fileformat to unix which will convert all linefeed characters to the unix style: set ff=unix
Hope that helps
在我提交有问题的文件后,我重新启动了工作站,现在一切似乎都按顺序进行(我尝试在同一存储库中编辑一些其他文件,并且差异很好)。
不知道发生了什么。我把这个写成“Windows”......
After I've committed the file in question, I've restarted the workstation and now everything seems in order (I've tried editing some other files in the same repo and diff was fine).
Have no idea what happened. I'm writing this one down as "Windows"...