Git – How to Deal with Merging Visual Studio Projects

gitmergingvisual studio 2010

Visual studio projects, as opposed to makefiles or other projects I know, have some quirks:

  • The directory structure of the project has no real connection to actual directory structure – all directories are purely virtual – this makes it harder to re-add mass of files while keeping directory structure
  • The project consists of rather complex XML, that file contains everything from files to compiler settings

Now whenever I merge branches, I have conflict on the project files, because everyone inadvertently changes them as they operate over the project. Often the changes happen in such ways that the merge tool does not even recognize conflict properly. In those cases, files end up missing in the project, outdated settings reappear and so on.

Our project is 2010 C++ solution consisting of five separate sub-projects.

Are there any strategies that would have low impact on the development process, but would alleviate problems caused by merging project files?

Best Answer

I find there are a couple things you can do to virtually eliminate this problem.

  1. More projects. Spreading code changes over more projects means less chance of a merge conflict and simpler projects files when you do get them.

  2. Build all your branches on the build server. This picks up build failures due to people forgetting to save the project when they add a file. Before they merge in their branch.

  3. Make everyone use the same version of visual studio

  4. Make sure as many settings as possible go in the .csproj.user file rather than .csproj and exclude this from source control.