git下的Resource.Designer.cs [英] Resource.Designer.cs under git

查看:63
本文介绍了git下的Resource.Designer.cs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在人们使用两个不同的IDE(Visual Studio和Xamarin Studio)来处理同一代码的环境中工作.不幸的是,它们生成的文件Resource.Designer.cs版本略有不同.这是一个自动生成的文件,但是在VC中我们确实需要它,否则在克隆后尝试构建该文件时项目会抱怨.

I work in an environment where people use two different IDEs (Visual Studio and Xamarin Studio) to work on the same code. Unfortunately, they generate slightly different versions of the file Resource.Designer.cs. This is an auto-generated file but we do need it in VC, or the project will complain when you try to build it after cloning.

这里的问题是我们在vc中确实需要此文件,但是微小的变化却非常令人讨厌.如果使用一个IDE提交项目,则有人将项目下载到另一个IDE中并进行重建,您会看到对该文件的更改.然后,如果您尝试切换分支,由于合并冲突,Git可能会拒绝.同样,如果您尝试合并两个分支,则可以保证在该文件的标题中看到合并冲突.

The problem here is that we do need this file in vc, BUT the tiny changes are highly annoying. If you commit the project with one IDE, then someone downloads the project into the other and rebuilds, you see a change to that file. Then if you try to switch branches, Git may refuse because of the merge conflict. Similarly, if you try to merge two branches, you are pretty much guaranteed to see a merge conflict in the header of that file.

如果两个人使用相同的IDE进行构建,但运行时版本略有不同,则会发生相同的问题.我现在正在看一个示例,在Git中显示以下更改:

The same problem occurs if two people build using the same IDE, but slightly different versions of the runtime. I am looking at an example right now with the following change showing in Git:

-  // Runtime Version: 4.0.30319.18444
+  // Runtime Version: 4.0.30319.34011

可以解决该问题的一种解决方法是仅此文件,让Git始终选择注释的本地"版本,而忽略注释的所有更改.但是我不知道是否有办法做到这一点.如果不是,是否有另一种方法来避免在文件更改很小的情况下经常遇到麻烦呢?

One fix that would solve the problem is, for this file only, to have Git always choose the "local" version of comments, and to ignore all changes to comments. But I don't know if there is a way to do that. If not, is there another way to avoid having constant hassles with small changes to this file?

推荐答案

我们的开发团队通过将 Resource.Designer.cs 提交到我们的Git存储库来解决此问题.之后,每个开发人员都可以运行 git update-index --assume-unchanged Resource.Designer.cs ,以使Git忽略对该文件的更新.

Our dev teams address this by committing the Resource.Designer.cs to our Git repo. After that, each developer can run git update-index --assume-unchanged Resource.Designer.cs to make Git ignore updates to that file.

更新索引后,对 Resource.Designer 文件所做的更改不会在执行 git status 时显示在未暂缓提交的更改"部分中.

After updating the index, changes made to the Resource.Designer file will not appear in the "Changes not staged for commit" section when doing a git status.

如果有必要提交该文件,只需执行 git update-index --no-assume-unchanged Resource.Designer.cs ,Git将再次开始跟踪对该文件的更改.

If a commit to that file becomes necessary just execute git update-index --no-assume-unchanged Resource.Designer.cs and Git will start tracking changes to that file again.

这篇关于git下的Resource.Designer.cs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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