Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference of merging from master branch and from dev branch

Tags:

git

merge

Assume that I've got a project with two branches. One is master and the other is dev. I'm using git and do either of the following:

Case 1

git checkout master
git merge dev

Case 2

git checkout dev
git merge master

My question: What is the difference of case 1 and case 2?

like image 402
N.N. Avatar asked Dec 22 '22 11:12

N.N.


2 Answers

git checkout master
git merge dev

Will checkout the 'master' branch and merge from the 'dev' branch. Any applicable changes within 'dev' will be in 'master' once this command has completed.

git checkout dev
git merge master

Will checkout the 'dev' branch and merge from the 'master' branch. Any applicable changes within 'master' will be in 'dev' once this command has completed.

For more information, take a look at Basic Branching and Merging.

like image 57
ChrisBint Avatar answered Jan 13 '23 13:01

ChrisBint


in the first case, the changes made in dev are merged to master (leaving dev unaffected)....whereas in the second case, the changes made in master (leaving master unaffected) are merged to dev. Please check this link for more details.

like image 33
reggie Avatar answered Jan 13 '23 12:01

reggie