Applying same file-rename changes to diverged GIT branches
I've got a project which has a master branch and a stable branch - the branches diverged long time ago. Now I've got a couple co开发者_运维知识库mmits on the stable branch, which I also want to have on the master branch (a bug fix). I cannot merge, as the branches diverged and there's loads of unmerged changes - I just want the 4 commits.
So I tried cherry-pick. However this fails since the top-level modules names changed from "project-module" scheme to "module". When cherry-picking, GIT creates the new files in the old directories (as on the old branch): the rename isn't detected. That's possibly because I get this warning:
warning: too many files (created: 278 deleted: 5364), skipping inexact rename detection
I tried git format-patch + git am, but this again creates the files in the old directories.
How can I apply the commits to the master branch?
Thanks, Adam
I suspect you could make it work (but take a long time) by changing the value of merge.renameLimit
:
merge.renameLimit
The number of files to consider when performing rename detection during a merge; if not specified, defaults to the value of diff.renameLimit.
I'm fairly certain cherry-pick will respect that value as well. If it doesn't, you could find a common ancestor of the two branches, apply the commits there, and then merge them into both branches, to make sure it's using the merge machinery. (Note that this is actually what I'd recommend doing in the first place. Merges are very much preferable to cherry-picks, because they don't create duplicate commits, and they preserve the flow of history.)
精彩评论