将相同的文件重命名更改应用于不同的 GIT 分支
我有一个项目,有一个主分支和一个稳定分支 - 分支很久以前就分叉了。现在我在稳定分支上有一些提交,我也想在主分支上有这些提交(错误修复)。我无法合并,因为分支分歧并且有大量未合并的更改 - 我只想要 4 次提交。
所以我尝试了樱桃采摘。但是,由于顶级模块名称从“项目模块”方案更改为“模块”,因此这会失败。当挑选时,GIT 在旧目录中创建新文件(如在旧分支上):未检测到重命名。这可能是因为我收到此警告:
warning: too many files (created: 278 deleted: 5364), skipping inexact rename detection
我尝试了 git format-patch + git am,但这再次在旧目录中创建文件。
如何将提交应用到主分支?
谢谢, 亚当
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 commits 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑您可以通过更改 merge.renameLimit 的值来使其工作(但需要很长时间):
我相当肯定,cherry-pick 也会尊重这个价值。如果没有,您可以找到两个分支的共同祖先,在那里应用提交,然后将它们合并到两个分支中,以确保它使用合并机制。 (请注意,这实际上是我首先建议做的事情。合并比樱桃选择更可取,因为它们不会创建重复的提交,并且保留历史记录流。)
I suspect you could make it work (but take a long time) by changing the value of
merge.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.)