EFanZh
EFanZh

Reputation: 2436

Is it possible to make git ignore UTF-8 BOM when commit?

I have some UTF-8 encoded text file, is it possible to make git to ignore the UTF-8 BOMs when commit? I know git can auto convert different EOLs ("\r", "\n", "\r\n"), but can I make git to ignore the BOMs and only commit the file contents?

PS: I already have a tool to remove text files's UTF-8 BOMs, but it's inconvenient, I have to run it every time before I commit, it will be more convenient if there's a way to make git to auto process the BOMs.

Upvotes: 8

Views: 3537

Answers (1)

user4815162342
user4815162342

Reputation: 155366

Use the pre-commit hook, which is designed for such a purpose.

Upvotes: 1

Related Questions