简体   繁体   English

.NET Git忽略空格

[英].NET Git ignore whitespace

I am using .NET, Visual Studio 2010 and Git in my development at work. 我在工作中使用.NET,Visual Studio 2010和Git。 I am looking for a way to make git ignore the white spaces due to different coding styles between our team. 我正在寻找一种使git忽略空白的方法,因为我们的团队之间存在不同的编码风格。

For readability, some of my colleagues really need to have some white spaces while others don't. 为了提高可读性,我的一些同事确实需要有一些空白,而其他同事则没有。

For example, some of us write code as: 例如,我们中的一些人将代码编写为:

var b = new B();

While others, write it as: 而其他人则写为:

var b = new B( );

Since git doesn't understand those white spaces, it threats them as changes. 由于git无法理解这些空格,因此会威胁到它们的变化。 However, that results in some merge conflicts and difficulties to see the actual changes in code. 但是,这导致一些合并冲突和查看代码实际更改的困难。 Is it possible to "make" git understand that this white space should be ignored? 是否有可能使git理解应该忽略此空白?

Thanks for any ideas! 感谢您的任何想法!

The correct fix for this would be to make all developers agree up on the same conventions. 正确的解决方法是使所有开发人员都同意相同的约定。

And as Jeow Li Huan points out, you can use StyleCop to enforce people actually comply to these conventions. 正如Jeow Li Huan指出的那样,您可以使用StyleCop强制人们实际上遵守这些约定。

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

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