Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge two branches with different directory hierarchies in git?

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).

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?

like image 339
anssias Avatar asked Jan 18 '11 09:01

anssias


People also ask

How do I merge 2 branches in git?

Merging Branches in a Local Repository To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch.


1 Answers

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 

then when done:

git config --unset merge.renameLimit 
like image 68
Robie Basak Avatar answered Sep 28 '22 21:09

Robie Basak