Merge conflicts in pbxproj

These are the peskiest merge conflicts. After spending days on resolving the same merge conflict, it makes you wonder whether it would be easier to copy and paste files.

Alternatively many people suggest prevention, and that you basically change your daily habits so as to avoid these conflicts. They encourage commiting changes and pulling frequently. While this is not a bad idea, it isn’t a guide on how to deal with merge conflicts when they happen and it isn’t great advice after the fact as well.

Here are the tricks I use to make resolving pbxproj conflicts as smoothly as possible.

  • Rebase when you want to resolve conflicts one by one, often, I find its easier to resolve all the conflicts at once with a pull or merge, When you rebase your way through conflicts, you may find yourself making changes that create conflicts as you go.
  • Pulling in the branch with the most changes first. When you pull in the largest branch first, you reduce the conflicts you will have to deal with when you cherry pick the incoming commits.
  • Using git cherry-pick with a range of commits instead of pulling in the whole branch which may have a conflicting base, which would cause major issues. git cherry-pick firstSha^..lastSha
  • use a git client like SourceTree.
  • Use a merge command in your .gitAttributes
  • Other habits to adopt: make a unique pr when refactoring file structures, and when refactoring other people’s code.