简体   繁体   中英

how to correctly merge several feature to main branch

Here I have a question. I have a main branch and 2 feature branches feature1 and feature2 which is checkout from main , when I finished developing these features, I want them to merge into main .

So I checkout a new branche named merge from main , and see what is going on after mergeing feature1 and feature2 yesterday. And from IDEA, it can be seen these 3 branches like this:

在此处输入图像描述

brown line is merge

green line is feature1

blue line is feature2

After testing, today I decided to merge feature1 and feature2 into another main 's branch in exactly the same method(checkout a new branch from main and merge feature1 and feature2 ) , but found this strange thing... IDEA showed the branch lines in quite an unapropriate way which like this:

在此处输入图像描述

No matter how I change the order of merging feature1 and feature2 it won't help, the branch line graph will always wrong. I don't know why this happening.Is there anything wrong with my merging movement?

I didn't touch my code at all,and no new commits at all, just checkout 2 new branches from main in different days, and doing the same merging process.

I would suggest always rebase before merging, so further merge will be just fast-forward and branch tree will be nice and clean. First, finish work on your feature1 , then checkout on it and execute git rebase master , resolve conflict, if presented. Then checkout on main branch and merge feature1 : git merge feature1 . Then do the same for feature2 : git checkout feature2 , git rebase master , git checkout master , git merge feature2 . Notice that this process better start from clean branches, not already messed-up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM