Take a look at
https://www.youtube.com/watch?v=3IMuHXZfIJs
https://docs.mendix.com/refguide/merge-dialog
https://www.mendix.com/blog/advanced-branching-merging-strategies-part-1-2/
During merging, select the first version and last version from your branch to merge it with Main line.