Merge strategies is a method to find out the common base commit while merging two branches on git.
Some of merge strategies:
- Recursive: this operates on two heads. recursive is the default merge strategy when pulling or merging one branch.
git merge -s recursive branch1 branch2
- Resolve: This can only resolve two heads using a 3-way merge algorithm. This tries to carefully detect criss-cross merge ambiguities and is considered as safe and fast.
git merge -s resolve branch1 branch2
- Octopus: This resolves more than two heads, but refuses to do complex merge that needs manual resolution. It is primarily used for bundling topic branch heads together. This is default merge strategy when pulling or merging more than one branches.
- Ours: This resolves any number of heads, but the result of the merge is always the current branch head.
- subtree: This is modified recursive strategy. When merging trees A and B, if B corresponds to subtree of A. Then B is first adjusted to match the tree structure of A.