'Ignore' binary files in git rebase 'theirs'

佐手、 提交于 2020-01-11 10:04:11

问题


I want to go from this

A - B - C - D - E - F - G 

where Branch1 is pointing at E and Branch2 is pointing at G

to this:

Branch1:    A - B - C - D - E
                     \
Branch2:              F - G

And I want Branch2 to always 'win', I've got as far as this:

git rebase -s recursive -X theirs --onto C Branch1 Branch2

That works fine - except that rebase chokes on binary files - saying it can't merge them. How do I go about telling git that I don't want to merge them, I just want to take 'theirs' each time?


回答1:


How do I go about telling git that I don't want to merge them, I just want to take 'theirs' each time?

That would be with a custom merge driver, that you can associate specifically with all binaries (*.dll, *.exe, *.so, ... whatever your particular binary extension is in your case)

See "git merge -s theirs needed — but I know it doesn't exist" for illustration.

What I haven't tested is: does the custom merge driver applies during a rebase --onto.




回答2:


The following is a shot in the dark:

From the git-rebase documentation:

   -m, --merge
       Use merging strategies to rebase. When the recursive (default)
       merge strategy is used, this allows rebase to be aware of renames
       on the upstream side.

       Note that a rebase merge works by replaying each commit from the
       working branch on top of the <upstream> branch. Because of this,
       when a merge conflict happens, the side reported as ours is the
       so-far rebased series, starting with <upstream>, and theirs is the
       working branch. In other words, the sides are swapped.

   -X <strategy-option>, --strategy-option=<strategy-option>
       Pass the <strategy-option> through to the merge strategy. This
       implies --merge and, if no strategy has been specified, -s
       recursive. Note the reversal of ours and theirs as noted in above
       for the -m option.

If -X implies --merge, and --merge swaps theirs and ours, maybe that's the problem. What happens if you switch theirs for ours?



来源:https://stackoverflow.com/questions/4507288/ignore-binary-files-in-git-rebase-theirs

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