Reputation: 541
I think the question is clear but just to elaborate, consider you have a branch X and you created a new branch Y from X. What happens to branch Y if I merge branch X into master. Can I merge branch Y into the master without any conflicts, if no one else has made any other changes on master whatsoever?
I found this entry but it doesn't seem like the same question. :)
Upvotes: 9
Views: 6691
Reputation: 3950
Child branches are not affected by merges of their parent branches. Branches are basically just a concept for human users, git only sees commits.
If you decide to merge the child branch into master at some point after its parent, git will find the already merged top commit of X being the common ancestor of Y and master.
Therefore git will only apply the changes of the commits between X and Y - as all commits before that are on master already.
Also: If you resolved conflicts while merging X into master, then the same conflicts will not reappear when merging Y into master, as the conflicts have already been resolved.
However: If you changed the previously conflicting lines in commits that are on Y only and the same lines on master do not look the same as on X anymore, then some new conflicts on the same line may occur.
Upvotes: 9
Reputation: 391286
Let's get a clearer picture of the situation.
You had this:
master
v
*---*
\
\
*---*---*---*---*---*---*
^ ^
X Y
You then merge X into master:
master
v
*---*-----------------*
\ /
\ /
*---*---*---*---*---*---*
^ ^
X Y
And now you want to merge Y into master.
This is entirely fine, and assuming, as you say, that no other changes have been made on master, there will not be any additional conflicts.
You will end up with this:
master
v
*---*-----------------*-----------*
\ / /
\ / /
*---*---*---*---*---*---*
^ ^
X Y
A similar situation would've arose if you had never made Y, merged X into master, but kept working on X, and finally merged X yet again into master, then you would just have this situation:
master
v
*---*-----------------*-----------*
\ / /
\ / /
*---*---*---*---*---*---*
^
X
Which is the same situation except for which branch names are involved.
Upvotes: 15