I want to know an exact algorithm (or near that) behind \'git merge\'. The answers at least to these sub-questions will be helpful:
How does git detect the context of a particular non-conflicting change?
How does git find out that there is a conflict in these exact lines?
If the same line has changed on both side of the merge, it's a conflict; if they haven't, the change from one side (if existent) is accepted.
Which things does git auto-merge?
Changes that do not conflict (see above)
How does git perform when there are multiple common bases for merging branches?
By the definition of a Git merge-base, there is only ever one (the latest common ancestor).
What happens when I merge multiple branches at once?
That depends on the merge strategy (only the octopus
and the ours
/theirs
strategies support merging more than two branches).
What is a difference between merge strategies?
This is explained in the git merge manpage.