How do I manage conflicts with git submodules?

前端 未结 8 1060
死守一世寂寞
死守一世寂寞 2020-11-30 20:29

I have a git superproject that references several submodules and I am trying to lock down a workflow for the rest of the my project members to work within.

For this

8条回答
  •  一整个雨季
    2020-11-30 20:44

    I struggled a bit with the answers on this question and didn't have much luck with the answers in a similar SO post either. So this is what worked for me - bearing in mind that in my case, the submodule was maintained by a different team, so the conflict came from different submodule versions in master and my local branch of the project I was working on:

    1. Run git status - make a note of the submodule folder with conflicts
    2. Reset the submodule to the version that was last committed in the current branch:

      git reset HEAD path/to/submodule

    3. At this point, you have a conflict-free version of your submodule which you can now update to the latest version in the submodule's repository:

      cd path/to/submodule
      git submodule foreach git pull origin SUBMODULE-BRANCH-NAME
    4. And now you can commit that and get back to work.

提交回复
热议问题