如何使用EOL Ctrl-M字符使github windows工具无法检出

时间:2013-12-16 09:39:17

标签: git github

我使用github工具检查了github中的代码。不幸的是,它使用Ctrl-M字符检出了文件。在其他版本控制工具中, SVN / Perforce,曾经有一个选项让工具在UNIX EOL模式下签出文本文件。我没有看到这样的选项。  我需要使用github windows工具检查我之后通过Linux VM使用的源,但是这个问题阻止了它。 Linux VM没有GUI,我需要用于差异的GUI以及管理大文件时的易用性。

我能想到的唯一另一个选择是使用cmd行从Linux中提取/推送/签出分支,或许只需使用Windows GUI进行差异。

1 个答案:

答案 0 :(得分:1)

请参阅http://git-scm.com/docs/gitattributes中的eol,我引用的地方:

End-of-line conversion While Git normally leaves file contents alone, it can be configured to normalize line endings to LF in the repository and, optionally, to convert them to CRLF when files are checked out.

Here is an example that will make Git normalize .txt, .vcproj and .sh files, ensure that .vcproj files have CRLF and .sh files have LF in the working directory, and prevent .jpg files from being normalized regardless of their content.

*.txt       text
*.vcproj    eol=crlf
*.sh        eol=lf
*.jpg       -text Other source code management systems normalize all text files in their repositories, and there are two ways to enable similar automatic normalization in Git.

If you simply want to have CRLF line endings in your working directory regardless of the repository you are working with, you can set the config variable "core.autocrlf" without changing any attributes.

[core]  autocrlf = true