TL;DR
The main difference lies in where the master
and dev
branches end up pointing.
Full explanation
Merging one branch into another is not a symmetric operation:
- merging
dev
into master
, and
- merging
master
into dev
,
are, in general, not equivalent. Here is an illustrative example that explains the difference between the two. Let's assume your repo looks as follows:
If you merge dev
into master
If master
is checked out (git checkout master
),
and you then merge dev
(git merge dev
), you will end up in the following situation:
The master
branch now points to the new merge commit (F
), whereas dev
still points to the same commit (E
) as it did before the merge.
If you merge master
into dev
If, on the other hand, dev
is checked out (git checkout dev
),
and you then merge master
(git merge master
), you will end up in the following situation:
The dev
branch now points to the new merge commit (F'
, whereas master
still points to the same commit as it did before the merge (D
).
Putting it all together
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…