gpt4 book ai didi

windows - .gitattributes 在 mac 和 windows 上不能正常工作

转载 作者:可可西里 更新时间:2023-11-01 11:11:49 25 4
gpt4 key购买 nike

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

# 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"

参见 https://git-scm.com/docs/gitattributes

关于windows - .gitattributes 在 mac 和 windows 上不能正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39995131/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com