Why would one use “git merge -s ours”?

前端 未结 6 1809
無奈伤痛
無奈伤痛 2021-02-02 13:46

I understand that the \"ours\" merge strategy (hear the quotes around merge?) actually does not use any commits from the other branch.

The \"ours\" strategy is

6条回答
  •  遇见更好的自我
    2021-02-02 14:12

    One use for this is as a preparation for another merge.

    Lets say you have some downstream changes that you want to merge with a new upstream version, but the new upstream version is not a git descendent of the old upstream version (maybe because the old upstream version was a stable branch that had diverged from trunk, maybe because the upstream versions were actually the results of an import tool).

    What you can do is.

    1. Check out the new upstream version.
    2. "psuedomerge" the old upstream version.
    3. Merge the new downstream version.

    In this way your local changes will be merged, but git will not try to merge the old upstream changes because it considers them to be already merged.

提交回复
热议问题