Reputation: 6091
We are working a couple of people on the same project using Visual Studio 2015 and git. This works reasonably well, expect for the .csproj
file (the project file). Everytime you add a new file to the project, the .csproj
file changes automatically. Hence if two (or more) people adds a file to their local version, it will require a merge from the last one who commits.
Is there a way to avoid this?
Edit: I can fetch, but not pull or commit. If I try to pull, Visual Studio Git wants to merge the remote .csproj
file with my local version. It cannot do this automatically however, and every attempt I have made to assist it results in a non-functional .csproj
file.
Upvotes: 7
Views: 11136
Reputation: 6091
For anyone reading this question here 5+ years later: If you still struggle with this, you probably need to upgrade to .NET 6 (or higher). The .csproj
file is a lot slimmer now, causing a lot less merge conflicts.
Upvotes: 0
Reputation: 489343
The .csproj
files Visual Studio creates are XML data. Git does not know anything about XML; it tries to merge these as ordinary text files. The result is rarely valid XML, and even more rarely anything resembling functional.
By default, when Git fails to merge these XML files, you will typically get a merge conflict: Git will stop and make you fix up the mess. It's up to you to get this right. Whether VS provides any tools to help, I have no idea (I avoid Windows). See also this description of the problem (this link is in the linked question's answer as well, but I figure I should include it as a direct link here).
Some people try to use union merge to fully automate the merging of these XML files, so that there is no Git conflict. This is not a good idea. See VS 2013 C# and Git: .csproj files don't merge upon pulling for details.
Upvotes: 8
Reputation: 23586
No need. Have You tried such flow? Were there many conflicts? Merge conflict in Git doesn't happen when couple people modify one file but when couple of people modify the same line. To be honest Git doesn't store files, but content. Files are just common way for human to deal with content.
So my answer is to try and see if there is any problem as Git auto resolver is quite clever and there is possibility that Your problem will be nonexistent.
Upvotes: -2