How I deal with Visual Studio solution and project files in Git?

后端 未结 3 1679
心在旅途
心在旅途 2021-01-31 09:31

I usually work with .NET using Git for versioning. In my team, we work in parallel and we often commit our code to integrate in the application. Everything is fine BUT the Visua

3条回答
  •  滥情空心
    2021-01-31 10:26

    Committing .sln and .csproj files is usually the best practice (as in this answer), but merging requires some attention.
    See "Why are my .csproj files getting messed up after a git rebase?".

    *.csproj -text merge=union (see below)
    *.sln -text merge=unionv

    Or you can give up on .csproj and regenerate them locally as in this tweet.
    Another reason to ignore those csproj files is if they are regenerated, as in this context

    yellowblood warns (in the comments) about serious conflict issue with csproj file when used with the merge=union strategy.
    That echoes the article "Merge conflicts in csproj files".
    That is why there is a suggestion for VS IDE should support file patterns in project files (in order to not modify the .csproj file if one add a new .cs file that fits that pattern).

    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.

提交回复
热议问题