简体   繁体   English

GIT CRLF到LF-UNIX上的git parent repo以及Windows和unix上的克隆

[英]GIT CRLF to LF - git parent repo on UNIX and clones on both windows and unix

This question is somewhat similar to my other question, make sure files are converted CRLF into LF in an update hook- is there a performance hit? 这个问题与我的其他问题有点类似,请确保在更新挂钩中将文件从CRLF转换为LF ,是否会对性能产生影响?

So here is what am looking for with the below architecture. 所以这就是下面的架构所要寻找的。 1. MY parent repository (bare and data) is on a UNIX machine. 1.我的父存储库(裸机和数据)在UNIX计算机上。 2. I can clone my repository in a UNIX machines. 2.我可以在UNIX计算机上克隆我的存储库。 3. I can clone my repository in a Windows machines using samba to access my parent repo. 3.我可以使用samba在Windows计算机中克隆我的存储库,以访问我的父存储库。

How can i take care of CRLF issues if 如果出现以下情况,我该如何处理CRLF问题

  1. The user creates clones in UNIX, maps it using samba into windows drive, the modifications are done in Windows which create a CR/LF character pair as the EOL. 用户在UNIX中创建克隆,使用samba将其映射到Windows驱动器中,修改在Windows中完成,从而创建CR / LF字符对作为EOL。 If the users come back to Unix and commits and pushes. 如果用户回到Unix并进行提交和推送。 How does GIT take care? GIT如何保养? or do we need to have some hooks in place? 还是我们需要一些挂钩?

  2. Same as above, but the file format exceeds 8000 characters per line - a lot. 与上述相同,但文件格式每行超过8000个字符-很多。 Is this treated as a ASCII file with the CR stripped out on commit? 将其视为提交时删除了CR的ASCII文件吗?

  3. Variation of 2, but it's a binary file which has an ASCII header. 2的变体,但是它是一个具有ASCII头的二进制文件。 Is this going to inadvertently have CR/LF's changed to LF? 这是否会导致CR / LF更改为LF?

The two places to look are Git-config and git-attributes . 要看的两个地方是Git-configgit-attributes

You will need to decide on your local standard, which will depend on your other external programmes, particularly corporate source control standards, and any tools that expect a particular format. 您将需要确定自己的本地标准,这取决于您的其他外部程序,尤其是公司源代码控制标准,以及期望使用特定格式的任何工具。

The manual pages feel a little confused at first and second reading. 手册页在第一次和第二次阅读时会感到有些困惑。 You need to note the cryptic codings such as 'working directory' means 'checked out' files, etc. 您需要注意神秘的编码,例如“工作目录”表示“已签出”文件等。

The 'default' is to 'normalise' which means that files committed to the repo would have LF endings. “默认”为“规范化”,这意味着提交到存储库的文件将以LF结尾。 Then with the right setting you can have checked out files as [always] LF, or [always] CRLF or chosen based on your [local] platform. 然后,使用正确的设置,您可以将文件检出为[always] LF或[always] CRLF或根据您的[local]平台选择文件。

I've no idea about the long lines, but I expect that git is quite happy with them. 我不知道长线,但我希望git对它们很满意。

For the special files with text headers etc, the git attributes file allows you to define file type and path specific check-in and check-out protocols (examples in the man pages. 对于带有文本标题等的特殊文件,git properties文件允许您定义文件类型和特定于路径的检入和检出协议(手册页中的示例)。

PS I've just been stuck on this myself with Matlab's *.m eol=LF ;-) PS我自己一直被Matlab的*.m eol=LF ;-)困扰。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM