使用 git 签入对 UTF8 BOM 的更改
我不小心从 Windows 签入了一个 utf8 编码的文本文件,之前没有删除 BOM。现在我尝试在更高版本中删除它并再次签入此更改。 git 似乎忽略了 BOM 字节的更改。是否有一个设置可以让 git 让我按原样签入文件? (我知道在行结尾方面存在类似的问题 - 并且有一个针对此问题的设置......)
I accidentally checked in a utf8 encoded text file from Windows without removing the BOM before. Now I tried to remove it in a later version and check-in this change again. It seems as git ignores the change to the BOM bytes. Is there a setting to make git let me check-in the file like it is? (I know there is a similar issue when it comes to line endings - and there is a setting for this one...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果你能让这个重现,一定要报告一个错误
这是我的两分钱:
验证不同的对象存在:
或者,稍微更直接
这是在 ubuntu 64 位上使用 git 1.7.4.1
If you can make this reproducible, by all means report a bug
Here's my two cents:
Verify different objects present:
or, slightly more direct
This is with git 1.7.4.1 on ubuntu 64 bit
git 不会忽略字节顺序标记 (BOM) 序列,并且 git 可以仅提交 BOM 删除。使用 xml UTF-8 进行测试
在 Visual Studio 2017 中通过文件 -> 另存为 -> 保存删除 Windows 上的 BOM编码->Unicode(UTF-8,无签名)。 git 看到更改,可以提交
git does not ignore Byte Order Mark (BOM) sequence and it is possible to git commit a BOM removal only. Tested with xml UTF-8
Removing BOM on Windows in Visual Studio 2017 through File->Save As->Save with Encoding->Unicode (UTF-8 without signature). git sees a change and it can be committed
如果找不到合适的解决方案,您可以随时向文件添加字符、提交、删除 BOM 和字母以及修改提交。
If you can't find a proper solution, you can always add a character to file, commit, remove the BOM and the letter, and amend the commit.