如何在git中合并具有不同目录层次结构的两个分支? [英] How to merge two branches with different directory hierarchies in git?

查看:34
本文介绍了如何在git中合并具有不同目录层次结构的两个分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在 Web 应用程序项目中使用 Maven,因此目录层次结构发生了变化.我为 Maven 集成创建了一个新分支.现在我有两个分支,一个是旧目录层次结构,一个是 maven 目录层次结构.两个分支都有新的提交(错误修正和新功能).

I started using Maven with a web application project so the directory hierarchy changed. I created a new branch for the Maven integration. Now I have two branches one with the old directory hierarchy and one with the maven directory hierarchy. Both branches have new commits (bugfixes and new features).

我想摆脱旧分支并将其更改合并到 Maven 分支.Git merge 带来了无数让人感觉无法解决的冲突.我相信这是因为文件路径发生了变化.

I would like to get rid of the old branch and merge it's changes to the Maven branch. Git merge gives countless conflicts that feels like impossible to resolve. I believe that this is because file paths have changed.

处理这种合并的最佳方式是什么?

What is the best way to approach this merge?

推荐答案

尝试将此合并的 merge.renameLimit 设置为较高的值.git 尝试检测重命名,但前提是文件数低于此限制,因为它需要 O(n^2) 处理时间:

Try setting merge.renameLimit to something high for this merge. git tries to detect renames, but only if the number of files is below this limit, since it requires O(n^2) processing time:

git config merge.renameLimit 999999

然后完成后:

git config --unset merge.renameLimit

这篇关于如何在git中合并具有不同目录层次结构的两个分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆