.gitattributes 在 Mac 和 Windows 上无法正常工作

2024-03-04

在我的项目中,我使用具有不同操作系统的计算机,一个是 Mac,第二个是 Windows。当我使用 git 时,每个更改都会显示为整个文档更改。原因是这两个操作系统中的行尾不同。我读了这个https://help.github.com/articles/dealing-with-line-endings/ https://help.github.com/articles/dealing-with-line-endings/并做了一个.gitattributes文件放在根文件夹中,但问题仍然存在。这是我的.gitattributes file:

# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.

*.css text
*.html text
*.js text

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

我不知道为什么它不起作用,因为我之前尝试过该文件的很多配置。


.gitattributes 文件应在第一次提交时添加。如果您添加一些提交,则需要显式规范所有现有文件。

$ rm .git/index     # Remove the index to force Git to
$ git reset         # re-scan the working directory
$ git status        # Show files that will be normalized
$ git add -u
$ git commit -m "Introduce end-of-line normalization"

See https://git-scm.com/docs/gitattributes https://git-scm.com/docs/gitattributes

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

.gitattributes 在 Mac 和 Windows 上无法正常工作 的相关文章

随机推荐