13

我们正在与几个拥有 Mac 的人一起开展一个项目,而我正在 Windows 上运行。我们遇到了换行符的一些问题。

我在 GitHub 上读到可以添加以下内容:

# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto

# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h 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

进入 .git 属性

但是我应该将该文件提交到 GitHub,以便其他使用 Mac 的人获得相同的设置吗?

如果重要的话,我们正在编写网站。(PHP、JavaScript 文件等)。

郑重声明,我是唯一一个使用 Windows 的人......所以,是的,我能做什么?

4

2 回答 2

13

首先,我建议先阅读文档

.gitattributes它建议在存储库的根目录或本地文件夹中签入文件.git.git/info/attributes.

后一个选项的影响可能最小(如果您是唯一的 Windows 用户)。

对于这种事情,我倾向于将责任放在团队中“喜欢与众不同”的任何人身上——例如,如果除了一个开发人员之外的所有人都在使用 Mac,而另一个开发人员正在使用 Windows,这真的应该取决于正在逆向整理的家伙。这没有恶意,只是公平的:-)

于 2013-02-26T13:30:21.253 回答
8

我添加了这个:

# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto

# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h 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

并将其提交到 GitHub 服务器。因此,遇到此问题的每个人都解决了问题。

于 2013-02-27T09:39:34.030 回答