【问题标题】:Should the .gitattributes file be in the commit?.gitattributes 文件应该在提交中吗?
【发布时间】:2013-02-26 13:17:23
【问题描述】:

我们正在与几个拥有 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 的人......所以是的,我能做什么?

【问题讨论】:

    标签: git merge


    【解决方案1】:

    首先,我建议先阅读documentation

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

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

    对于这种事情,我倾向于将责任放在团队中“喜欢与众不同”的人身上——例如。例如,如果除了一个开发者之外的所有开发者都使用 Mac,而另一个开发者使用 Windows,那么 真的 应该由那些违背常规的人来解决。这没有恶意,只是公平:-)

    【讨论】:

    • 是的,我知道。但是我已经阅读了文档,但无法确定该文件是否应该来自 git 服务器。
    • 你的意思是字面意思在git服务器上还是checked in
    • 我对 Git 不太擅长,因为我刚发现它。但是当我尝试提交时,它要求我将文件上传到服务器,我做到了..它实际上解决了问题:O 那么我该怎么办? xD 我是回答自己的问题还是什么?
    【解决方案2】:

    我添加了这个:

    # 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 服务器。因此,遇到此问题的每个人都解决了问题。

    【讨论】:

      猜你喜欢
      • 2022-08-06
      • 1970-01-01
      • 1970-01-01
      • 2017-11-17
      • 2020-11-11
      • 2011-06-16
      • 1970-01-01
      • 2015-10-24
      • 2015-03-17
      相关资源
      最近更新 更多