在一个文件中改变一个字符导致MSysGit思考整个文件已经改变 [英] Changing one character in a file leads to MSysGit thinking the whole file has changed

查看:132
本文介绍了在一个文件中改变一个字符导致MSysGit思考整个文件已经改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含C#代码一个Git仓库,和我跑 MSysGit 在Windows上。

I have a git repository containing C# code, and I'm running MSysGit on Windows.

core.autocrlf 开启,而我使用 .gitattributes 来自的this问题和我renormalised我的回购= https://help.github.com/articles/dealing-with-line-endings相对=nofollow>这个Github的指南。

core.autocrlf is turned on, and I'm using the .gitattributes from this question, and I "renormalised" my repo as mentioned at the bottom of this Github guide.

现在为的部分的的的的.cs 的在我的仓库里的文件,如果我改变甚至一个字符, MSysGit 认为整个文件已经改变了。

Now for some of the .cs files in my repository, if I change even one character, MSysGit thinks the whole file has changed.

我克隆库的新鲜。我试图在Visual Studio中首先编辑文件,但后来我试着赛特打开它,显示了我。行结束和制表符,而我也相信它不会做任何奇怪的文件(如更改编码)

I cloned the repository fresh. I tried editing the file first in Visual Studio, but then I tried opening it in SciTE which shows me line ending and tab characters, and also I trust it not to do anything weird to the file (like change the encoding).

所以,我的新鲜克隆库:

So, I clone the repository fresh:

$ git clone git clone git@git.assembla.com:my-repo.v2.git
$ cd my-repo/

我检查库和文件:

$ git status
# On branch master
nothing to commit (working directory clean)
$ git diff path/to/myfile.cs
$

我打开赛特文件(注意行结束 CRLF ,也没有标签):

I open the file in SciTE (note that the line endings are CRLF and there are no tabs):

using System;
using System.Collections.Generic;
...

和改变一个字符(请注意, CRLF 无标签是仍然如此):

and change one character (and note that CRLF and no tabs are still true):

using System;
!using System.Collections.Generic;
...

和现在的git认为一切都变了:

and now git thinks everything's changed:

$ git diff path/to/myfile.cs
diff --git a/path/to/myfile.cs b/Dpath/to/myfile.cs
--- a/path/to/myfile.cs
+++ b/path/to/myfile.cs
@@ -1,116 +1,116 @@
-<U+FEFF>using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Practices.EnterpriseLibrary.Data;
-using DataModel.Models;
-using DataModel.Mappers.Interfaces;
-using System.Data.Common;
-using System.Data;
...

一个正常的diff程序并不认为这两个文件是如此不同和 git的差异在Unix并不认为他们太不同,但 msysgit 一样。

A normal diff program doesn't think the two files are so different, and git diff on Unix doesn't think they're too different, but msysgit does.

任何以往任何时候都遇到这样或有什么想法?

Anyone ever encounter this before or have any ideas?

推荐答案

一个几件事可以使显示的Git作为改变了整个文件:

A few things that can make Git show the entire file as changed:


  • 行结束 - 但你说你检查了这些,他们是一样的;

  • 压痕 - VS(特别是如果你已经安装了一些扩展),可能会改变从标签以空格或反之亦然缩进。你可以用显示空白(按Ctrl-R,CTRL-W在VS或在不同的相关选项),检查此

  • 编码 - 如果VS决定重新编码在一些不同的编码(如UTF16),它可能会显示文件彻底改变虽然文字表述看起来是一样的。

这篇关于在一个文件中改变一个字符导致MSysGit思考整个文件已经改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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