I have this branch situation in my GIT project:
- Blue is the my principal branch
- Red and Yellow are branches where I'm writing tho different features
Red and Yellow are not completed and I would like integrate the Blue into Red and Yellow without close them. In this mode I can continue to work in Red/Yellow updated branch and when I will close them I will find less conflict.
How can I do this? rebase
? merge
?
git merge
does exactly what you need.You didn't provide the names of your branches. I'll assume their colors are their names.
makes the red branch current then brings into it the changes introduced by the three blue commits since the red branch was created.
Similar,
brings into the yellow branch the same three commits; notice the blue branch was merged in the yellow branch before and only these three commits since the last merge are missing from the yellow branch.
If you follow the yellow branch backwards, its last two commits are merges from the green branch (created using
git merge green
) and the third commit is a merge from the blue branch (created usinggit merge blue
).git rebase
does a different thing, it is not useful for your goal. It can be used when you have a feature branch (the red and yellow branches in your scenario) and you want to move the commits it contains on top of the main (blue) branch, as if they were created after the current state of the blue branch.