有没有办法强制 git 添加忽略行结束问题?

Is there any way to force a git add ignoring line ending problems?

我有一个巨大的目录,我需要将其导入 git,我正在为行结束管理而苦恼。

最初我只需要将所有内容都放入回购协议中,没有时间处理行尾。为此,我添加了一个带有 * -text.gitattributes 文件,但这并没有解决问题,因为有很多子目录包含具有自己的 .gitattributes 文件和 text=auto.

有没有什么办法可以毫不费力地获取存储库中的所有文件?

gitattributes documentation 状态:

When deciding what attributes are assigned to a path, Git consults:

  • $GIT_DIR/info/attributes file (which has the highest precedence),
  • .gitattributes file in the same directory as the path in question, and its parent directories up to the toplevel of the work tree (the further the directory that contains .gitattributes is from the path in question, the lower its precedence).
  • Finally global and system-wide files are considered (they have the lowest precedence).

If you wish to affect only a single repository (i.e., to assign attributes to files that are particular to one user’s workflow for that repository), then attributes should be placed in the $GIT_DIR/info/attributes file.

因此请尝试在 $GIT_DIR/info/attributes 中设置您的 * -text 指令,至少对于您的初始添加和提交。