使用代码分发 git 配置 [英] Distributing git configuration with the code

查看:31
本文介绍了使用代码分发 git 配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试为开发人员标准化平台时,我的需求之一是提交 .git/config 以便每个人都拥有相同的 CRLF 配置而不会忘记手动设置.

In trying to standardise the platform for the developers, one of my needs would be to commit the .git/config so that everybody have the same CRLF config without forgetting to set it by hand.

我该如何设置?

我有点担心所有这些对 autocrlf 的负面影响.如果它不起作用,为什么不删除此功能?要么这个功能的创造者被误解了,要么他们做了一个失败的实验,应该删除它以阻止更多的人浪费时间(阅读晦涩的手册页,提出问题,人们回答这些问题等).

I'm a bit concerned by all this negativity against autocrlf. Why not remove this feature if it doesn't work? Either the makers of this feature are misunderstood or they made a failed experiment with it and it should be removed to stop more people from wasting their time (reading the obscure man page, asking questions, people answering those questions etc.).

推荐答案

我一直发现 autocrlf 配置属性有问题.(如我的回答中所述 Windows 上的 Git 1.6.4 beta (msysgit) - Unix 或 DOS 行终止)

I have always found the autocrlf config property problematic. (as expressed in my answer Git 1.6.4 beta on Windows (msysgit) - Unix or DOS line termination)

注意:msysgit issue 538 用于设置为 true(这是 msysgit 安装程序设置的默认值),但我不相信.

Note: msysgit issue 538 for setting it to true (which is the default value set by the msysgit installer), but I am not convinced.

我更喜欢以下三种解决方案之一:

I would prefer one of the three following solutions for:

  • 配置一种行尾样式
  • 使该配置通过不同的 Git 存储库传播

首先:git config --global core.autocrlf false
然后:

1.使用新的 配置设置 core.eol (1.7.2+)

1. Using the new config setting core.eol (1.7.2+)

为设置了 text 属性的文件设置要在工作目录中使用的行结束类型.
替代方法是lf"、crlf"和native",它们使用平台的本机行结尾.
默认值为原生.

Sets the line ending type to use in the working directory for files that have the text property set.
Alternatives are 'lf', 'crlf' and 'native', which uses the platform's native line ending.
The default value is native.

2.a 结帐/检查.gitattribute.请参阅 gitattributes 手册页:crlfcore.autocrlf 是在 .gitattributes 文件中记录以前是本地配置属性的方法.

2. a checkout/checking .gitattribute. See gitattributes man page: crlf or core.autocrlf is the way to record in a .gitattributes file what is was previously a local config attribute.

您可以添加结帐/签入属性,例如:

*.vcproj    text eol=crlf
*.sh        text eol=lf

3.一个 git 属性过滤器驱动程序,它可以:

  • 强制执行您可能想要设置的任何类型的格式标准
  • 将这些标准应用于某些文件/目录
  • 记录为配置文件 (.gitattributes),可以推送到任何地方.
  • enforce any kind of formatting standard you may want to set
  • apply those standards to certain files/directories
  • be recorded as a config file (.gitattributes) able to be pushed anywhere.

这篇关于使用代码分发 git 配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆