Is there any difference between
git merge c1 c2
and
git merge c2 c1
? Also, is there any difference between
git checkout c1
git merge c2
and
git checkout c2
git merge c1
?
Is there any difference between
git merge c1 c2
and
git merge c2 c1
? Also, is there any difference between
git checkout c1
git merge c2
and
git checkout c2
git merge c1
?
The end result in terms of the file content should be the same in all cases you described.
But there will be a difference in the DAG, in the ordering of commits in the graph of all commits, for example:
git merge c1 c2
* dd24250 (HEAD, master) Merge branches 'c1' and 'c2'
|\
| * 9d09bec (c2) change in c2
* | 1f5c0ca (c1) change in c1
|/
git merge c2 c1
* 3256c8d (HEAD, master) Merge branches 'c2' and 'c1'
|\
| * 1f5c0ca (c1) change in c1
* | 9d09bec (c2) change in c2
|/
git checkout c1; git merge c2
* 111e7da (HEAD, c1) Merge branch 'c2' into c1
|\
| * 9d09bec (c2) change in c2
* | 1f5c0ca change in c1
|/
git checkout c2; git merge c1
* 8ccf531 (HEAD, c2) Merge branch 'c1' into c2
|\
| * 1f5c0ca (c1) change in c1
* | 9d09bec change in c2
|/
I'd start with the second question.
The resulting tree objects in the merge commits will be identical. However the two commit objects won't be:
The order of the two parent commit objects will be different.
Which may lead to subtle differences when referring to commits with the HEAD^1~5
notation.
The same applies to the first question:
1st case, 1st parent = current branch last commit, 2nd parent = c1 last commit, 3rd parent = c2 last commit.
2nd case, 1st parent = current branch last commit, 2nd parent = c2 last commit, 3rd parent = c1 last commit.