开发者

git: merge file that has been reordered

I have a branch in which I've been doing some surgery on a single (Python) file, while development continues on the same file in the main branch. Normally this is easily dealt with by git merge, but one of the bigger changes I've made was to reorder the classes inside the file. As a result, git's merge algorithm is getting hopelessly confused. Is there a way to tell it to merge a particular part of the file from one side, with a differ开发者_如何转开发ent part on the other side?


Using the patience strategy (-s patience) might help a little, because it matches on the unique lines in the file instead of repeated lines. The other option that comes to mind is to do an interactive rebase (-i) instead of a merge, which lets you go patch by patch if you like. There isn't an interactive option for merge. Other than that, it's just one of those situations where you have to bite the bullet and do it the hard way. Using a graphical merge tool can make it a lot easier.


You can specify an entire file to overwrite the other with git merge -s ours branch, but I'm not aware of a way to split a file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜