I am facing merge conflict with Copter-3.5.2 code. I had forked Ardupilot repo to my git account and was using branch copter-3.4.5. I could successfully merge to 3.4.6 without any issue. When I merge 3.5.2 to 3.4.6 I am seeing many conflict file. Trust me, I have never modified those files. Conflict pics attached. I have also tried the rebase approach but same conflict messages. For rebase I have done the followings
git checkout Copter-3.5.2
git rebase Copter-3.4.6
git add .
git commit -am “commit message”
git checkout Copter-3.4.6
git merge 3.5.2
I assume that there should not be any conflict between 3.4.6 and 3.5.2 as I have not changed any files. Please correct me if I am wrong. and let me know the steps to safely merge these two branches.
Sorry, but yes, you are wrong. There are merge conflicts between those branches that you need to fix by hand. No script, or automated program can do that for you.
And you need to understand the code in order to do it. Sorry there is no other way.
I advise you to instead rebase the changes you did to the 3.4.6 branch on top of 3.5.3.
To do so put all your changes on a single branch on top of 3…4.6 and then:
git checkout -b my_new_rebased_branch
git fetch origin Copter-3.5.3
git rebase origin/Copter-3.5.3
solve the conflicts.
Your old branch will still be in the same place, but you now have a new branch called my_new_rebased_branch on top of the latest stable version.
Hi amilcarlucas, I mean as I have not edited any file it should just merge. And I should not see merge conflicts. I am not getting your point. Is there something different happened between 3.4.6 and 3.5.2? Because when I merged from 3.4.6 to 3.4.5 I didn’t see many merge conflicts only one conflict in Version.h. Please some one answer this.
No, because the file may have been changed by commits from other developers from 3.4 -> 3.5. So it won’t automatically merge. You need to use a diff code editor like Meld on linux and manually solve the conflicts using ‘git mergetool’ and defining mergetool to use your favorite diff code editor.
There are many changes from 3.4 to 3.5, and only basically one change from 3.4.5. to 3.4.6. So merging from one point release to the next is minor compared to merging two major releases.
I believe Ardupilot is growing commit by commit and people are resolving conflicts. And I am assuming the Dev team must have resolved all the conflicts before creating a pull request for 3.5.0. As I mention I haven’t done any changed to 3.4.5, I should not see so many conflicts. On the other hand I have tried merging 3.4.0 with 3.4.6 which is 50 plus file changes and it merge without conflict. There is something wrong between 3.4.5 and 3.5.0.
If you haven’t changed anything, why even go through this process? Just pull upstream and checkout the branch you want.
Indeed. That would be much easier. Because there has been major changes to the servo library, EKF, motors library, you name it. There is no way you will be able to merge that without a full day of manually resolving conflicts.
If you have a specific dev branch where you worked on a feature, bug fix, etc., then get your local repo up to date with 3.5 with a git pull and cherry-pick your custom code commits from your dev branch into a new dev branch based on 3.5 (or whatever you’re using for master). Chances are the dreaded conflict will pop up again and you’ll have to resolve it manually.
Otherwise I don’t see the point of trying to merge one major release into another one. That’s not how ArduPilot development is done. PR’s are made to master (currently 3.6-dev). Selected PR’s go into 3.5-Backports for the next point release. Eventually a snapshot of master is taken and becomes the first 3.6 release candidate. Each major release diverges from the previous one to such an extent that even backporting becomes an issue, much less trying to merge an obsolete codebase into the next major release version.
The only thing wrong between 3.4.5 and 3.5.3 (the current stable) is that just about everything has changed - more than once. And there’s the source of your conflicts. Clone the current stable (Copter-3.5), run git log and look at the changes since 3.4.6 was released. The problem with doing a git merge should then become self-evident, as it just doesn’t work that way.
Just do the rebasing steps that I posted. And you will solve a lot of current and future headaches.
Thanks everyone for your support. I have merged to 3.5.2 and the code works. I had to spend a day and manually do it.
Rebasing it over and over again, has proved itself as being the best option for us.
Most times it takes less than 2 seconds.