I'm working on a project which has different branches with different developers. Each project has submodules and .gitmodules differs in every branches, so this cause a merge conflict when the main branch holder try to merge. I tryed different way to resolve it but with no results, imagine that I have no access on the main branch.
Anyone that encounter my same problem? How did you resolve it? Thank you in advance.
CodePudding user response:
Whenever you want to merge something into master, the best approach is to create a branch where you create the end state you want on master, and merge/PR that branch.
So when a developer wants to merge something from their project branch to master, they would create a new branch, merge master into it (if necessary), fix any and all conflicts and bring it to the state that makes sense with respect to master, which includes fixing the .gitmodules configuration in your case. They would then submit a PR to merge that branch into master. There should be no conflict now, since the conflicts were resolved before doing the PR.
This advice holds for any and all PRs: it's good practice to make the person submitting a PR resolve the conflicts on the PR branch, rather than have the owner of the master branch do it. And even when the owner resolves the conflicts for the submitter, they can do it on the PR branch before accepting the PR. (I might do that for one-time contributors if I don't think it's worth teaching them how to resolve their conflicts, but I consider it a good learning opportunity so I generally prefer to spend the time showing the contributor how to do it instead.)