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

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

    Another use is as an alternative to a force-push that doesn't cause non-fast-forward changes for others.

    E.g. you want to revert an incoming (stupid) commit, but you don't want to do git push -f because then you'll spend the next half-hour guiding your client through recovering from that, and you want a shorter alternative to

    git checkout -b temp remote/origin
    git revert HEAD
    git push temp:origin
    git checkout master
    git merge origin/master
    

    so you simply do

    git merge -s ours origin/master
    

提交回复
热议问题