what causes submodule conflicts in git, and how should they be resolved?

后端 未结 2 1695
-上瘾入骨i
-上瘾入骨i 2021-02-04 13:18

We are using submodules and we are new to git.

We often see merge conflicts for the submodules themselves, no files are conflicted, just the submodule. There are multip

相关标签:
2条回答
  • 2021-02-04 13:50

    Both file conflicts and submodule conflicts occur when your current branch and the branch-you-want-to-merge-into have diverged.

    It merely means an ambiguous situation exists -- you could legitimately want either to "win" in any given case. So, while it may seem "annoying", they merely highlight your rich options to specify what you want (and you must specify what you want). (And, all that programmers do every day is merely to specify detail.)

    It seems like the git-add-the-submodule-on-the-superproject should have worked. However, you also had the option to git-checkout-on-the-superproject right away. This is mentioned in this link (resolving submodule conflicts), which talks about the difference between file conflicts and summodule conflicts, and how to resolve them:

    http://pacific.mpi-cbg.de/wiki/index.php/Git_Conflicts

    0 讨论(0)
  • 2021-02-04 13:54

    Your local submodule and the remote submodule have diverged.

    git checkout --theirs submodulename
    

    or for your version:

    git checkout --ours submodulename
    

    and then commit the changes with git add and commit the changes.

    Note: Your shell may add a trailing slash to the submodulename if you tabcomplete, since it is also a subdirectory. If so, you need to delete it or you'll get:

    error: pathspec 'submodulename/' did not match any file(s) known to git.
    
    0 讨论(0)
提交回复
热议问题