什么时候 .gitattribute eol 设置为 运行?

At what point will .gitattribute eol settings be run?

向存储库根目录中的 .gitattributes 文件添加一行后:

*.tt eol=crlf

哪个进程将在什么时候应用此规则并更改行尾;在 mergecommitpush?它将 运行 它们在客户端或存储来源的任何位置(bitbucket、stash、github)?是否因操作系统而异?

Checking out和checking in下的git man page for .gitattributes有点模糊:

These attributes affect how the contents stored in the repository are copied to the working tree files when commands such as git checkout and git merge run. They also affect how Git stores the contents you prepare in the working tree in the repository upon git add and git commit.

这些更改的确切时间是什么时候?

这与 .gitconfig 中的设置有何不同?

行尾转换在

时完成
  1. 文件从索引复制到工作目录(在您的示例中,这是将 CR 映射到 CRLF 的时间)
  2. 文件从工作目录复制到索引(在您的示例中,这是将 CRLF 映射到 CR 的时间)。

由于 merge 将文件添加到索引(除非发生冲突),规则确实是 运行 在 merge 上。从技术上讲,它不会发生在 commit 上,因为 commit 只是将文件从索引复制到存储库,但是如果您传入 -a 选项,那么文件确实会复制到索引,然后执行规则。 checkout 将文件从索引复制到工作目录,因此规则也将被执行。在 push 期间没有执行任何规则。