How to make a Git merge operation ignore identical changes made to both branches?

前端 未结 1 773
一个人的身影
一个人的身影 2021-01-07 17:38

Lets assume that we have one development branch \'A\', and two sub branches \'B1\' and \'B2\', (both taken from A). Lets say that you run a format code command (in

相关标签:
1条回答
  • 2021-01-07 18:14

    Yesterday I had similar issue after a lot of cherry-pick from (and to) a side branch where I after merged with my main branch. A lot of conflicts with identical change. I solved this with a merge strategy:

    git checkout main-branch
    merge --no-commit -s recursive -X ours side-branch
    

    you can change "ours" to "theirs". Be careful because all conflicts are automatically solved choosing "ours" or "theirs" side. In my case I had few mis-merges due to this, and I fixed manually. See others interesting options of merge strategies here: https://www.kernel.org/pub/software/scm/git/docs/git-merge.html

    You can also try to use a rebase (in my case it did not work well because the branchs were too different and I had a new conflict in each new rebase interaction). See this: http://davitenio.wordpress.com/2008/09/27/git-merge-after-git-cherry-pick-avoiding-duplicate-commits/

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