git merge recursive theirs, how does it work?

后端 未结 2 658
礼貌的吻别
礼貌的吻别 2020-12-24 11:48

I\'m having a bit of a problem. We have our own CMS which is using git for collaboration and versioning and stuff.

Now I have two git repositories A and B, A which i

相关标签:
2条回答
  • 2020-12-24 12:07

    You must use this form to pass merge strategy options:

    git merge -s recursive -Xtheirs # short options
    git merge --strategy recursive --strategy-option theirs # long options
    

    Also make sure your version supports -Xtheirs, that's a quite recent feature(?)

    0 讨论(0)
  • 2020-12-24 12:19

    I think the reason it's failing is that you are specifying "recursive theirs" as the strategy. "recursive" is a strategy, and when you put a space after it, "theirs" is interpreted as something git needs to merge your working copy with (eg. another branch or refspec).

    I think you will not be able to specify a strategy exactly like what you want. There is a strategy called "ours" which is the opposite of what you are wanting.

    The usual pattern used in this situation is to either merge or rebase to the "B" repository. From within the "A" repository's working copy, you would do a rebase, if possible (it might not be possible, if you are already sharing the git repo with other developers). A rebase would essentially roll the A repository back to a common commit within both repositories, apply "B" commits, then "A" commits on top. You'd resolve any merge conflicts along the way.

    Once you go thru the pain of either merging or rebasing to the "B" repository, the future merges will be less painful.

    0 讨论(0)
提交回复
热议问题