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

前端 未结 6 1802
無奈伤痛
無奈伤痛 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:22

    I'm using this pseudo-merge in an additional branch used to track the other branches, including abandoned ones. This additional branch has in fact only one file (called branches-list), which contains a text list of the active and inactive branches, but at the important points (mostly branch-points and "end-of-branch", either merge or abandon) the development branches are merged (with "-s ours") to this branch.

    Here a recent screenshot of our project:

    screenshot

    Thus, I lastly branched elo-test from master, and then from this I branched stroke-transform-example for my question here (and the answer - this should have been two different commits, though). At each such branch-point, and more importantly, at each point when a branch ends without it being merged to some other branch (which will happen to stroke-transform-example when I next clean up), I now merge this branch with -s ours to the meta-branch branches.

    Then I can later delete the not-used-anymore branches without losing their history, so the output of git branch -a is always quite small. If I then ever want to look back at what I did then, I can easily find them.

    (I think this is not really what this option is made for, but it works quite nice.)

提交回复
热议问题