我在工作场所的 Windows 上的 CVS 存储库中本地使用 cygwin-git,以便至少获得 dvcs 的一些优势。我的问题是 git diff 在 diff 中几乎显示了整个文件。通常是这样的:
+ source code line...
- source code line...
(额外的加号和减号,因为 SO 将单个加号/减号转换为项目符号)
如果我执行 git diff --ignore-all-space
,我可以看到相关的更改代码,但提交不必要地大,因为它包含所有更改。
在 CVS 中使用 git repo 的整个想法是,它可以更容易地完成原型(prototype)工作,然后我可以有选择地 merge 到 CVS 中。但是,如果每两行都出现在 diff 中,则选择性 merge 是不可能的。请帮忙!
附言
我已经阅读了一些关于 SO 的其他空白线程,并且我将 core.whitespace 设置为 -trailing-space
并将 core.autocrlf
设置为 true。但是,这些设置似乎没有任何区别。
要进一步详细说明这个问题,git diff --ignore-all-space
怎么可以忽略这个问题?我可以做什么设置,以便 git commit 可以做同样的事情?将不胜感激!
最佳答案
修好了。问题是 CVS 和 git 使用了不同的 eol 规范化。因此,git-diff 显示出如此多的变化。解决方法是在根目录中有一个 .gitattributes 文件,其中包含如下条目:
* text=auto
来自git-attributes页:
If you want to interoperate with a source code management system that enforces end-of-line normalization, or you simply want all text files in your repository to be normalized, you should instead set the text attribute to "auto" for all files.
关于Git 和大量空白问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3110707/