Is it possible to do a partial merge with --ff-only changes?

瘦欲@ 提交于 2019-12-06 05:55:06

git read-tree is the low-level merge prep, everything short of actual conflict resolution. One easy way is

git merge-s ours --no-commitother# no-op merge, just sets up parents
git read-tree -um $(git merge-baseHEADother) HEADother
#manual resolution here
git commit

which leaves everything with different new content in both branches for manual resolution but accepts all at-most-one-new-version files. You might want read-tree's --aggressive option, to handle whole-file deletion and addition as an ordinary change.

As a safety play for an unlikely case, check the output of git merge-base--all HEADother. If that shows multiple bases (as it will when the most recent merges on each branch have common parents), git's (default) "recursive" merge strategy would have derived base content that produces better automatic resolution results than the actual bases, and you might want to take extra care with your manual resolution.

VonC

You could declare a merge driver similar to "Git - how to force merge conflict and manual merge on selected file".

That driver would use git merge-file, except you can test its exit value:

The exit value of this program is negative on error, and the number of conflicts otherwise.

If the merge was clean, the exit value is 0.

So if it returns 0, you can let the merge continue (your merge driver exits with status '0')

In any other cases, you will force a manual merge by exiting with a status '1'.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!