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
?
However, Git always uses a single algorithm for computing both L and R, so the order does not matter here. To put this another way, if you manage to produce a Doppelgänger file—one that has different content from, but the same hash as, some existing file, Git simply refuses to put that file into the repository.
It is called so because, in the 3-way merge, Git uses three commits to generate the merge commit; two branch tips and their common ancestor. Typically, the fast forward merge is used by developers for small features or bug fixes while the 3-way merge is reserved for integrating longer-running features.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With