Always use version from merged branch on conflicts

前端 未结 2 2005
不思量自难忘°
不思量自难忘° 2020-12-15 00:27

Currently I am working in a feature branch that will soon be merged back into master. I recently tried just that and had some merge conflicts, which I had to fix manually. <

2条回答
  •  无人及你
    2020-12-15 01:15

    You can do exactly this in git with the following command, assuming that feature is the name of your feature branch:

    git merge -s recursive -X theirs feature
    

    This says to use the "recursive" merge strategy, but with the "theirs" option. This means that when there is a conflict, it will be automatically resolved by taking the version of the hunk from the feature branch, not your current branch. (Note that this is completely different from the "theirs" merge strategy, which has now been removed from git.)

    This feature was introduced in git v1.7.0.

提交回复
热议问题