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

git

Solution

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

Problem

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.

Original source