我通常使用 Git 进行版本控制来处理 .NET。在我的团队中,我们并行工作,我们经常提交代码以集成到应用程序中。一切都很好,但 Visual Studio 的解决方案和项目文件。我们找到了两种方法:
- 永远不要提交那些文件,每个人都有自己的
- 在版本系统中包含这些文件
这两种方式各有利弊,但基本上每次我们从中央 repo 中提取数据时都会遇到困难。这里有一些我们发现的备用问题:(在括号中,引用上面的列表)
- 我们必须在项目中包含其他人的文件 (1) 或包含我们最新的文件 (2)
- 如果我们在不同的架构 (x86/x64) 上工作,我们必须手动更改
.csproj
文件 (2) - 针对引用和 NuGet 包回复了相同的问题
等等。 是否有适合我使用的工作流程?
最佳答案
提交 .sln
和 .csproj
文件通常是最佳实践(如 this answer 中所示),但 merge 需要一些注意。
参见“Why are my .csproj
files getting messed up after a git rebase
?”。
(见下文)*.csproj -text merge=union
*.sln -text merge=union
v
或者您可以放弃 .csproj
并在本地重新生成它们 as in this tweet .
忽略这些 csproj 文件的另一个原因是它们是否重新生成,如 in this context
yellowblood当与 merge=union
策略一起使用时,警告 ( in the comments ) 关于 csproj
文件的严重冲突问题。
这与文章“Merge conflicts in csproj
files”相呼应。
这就是为什么有一个 suggestion for VS IDE should support file patterns in project files (为了不在添加符合该模式的新.cs
文件时修改.csproj
文件)。
It's been suggested that if Visual Studio sorted its elements first, that would help mitigate the problem.
That helps reduce the incidental conflicts caused by Visual Studio's apparent non-deterministic sort of elements.
But it doesn't make the issue of merge conflicts go away.
关于c# - 我如何在 Git 中处理 Visual Studio 解决方案和项目文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21511959/