Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git merge --strategy vs. --strategy-option

Tags:

git

git-merge

What is the difference between the git merge option --strategy-option (short -X) and --strategy (short -s)?

There are a lot of questions regarding merge strategies. But none explain the difference between these options.

Also the git documentation is not helpful:

--strategy-option Pass merge strategy specific option through to the merge strategy.

like image 838
Matthias M Avatar asked Dec 11 '17 12:12

Matthias M


People also ask

What is the best git merge strategy?

The most commonly used strategies are Fast Forward Merge and Recursive Merge. In this most commonly used merge strategy, history is just one straight line. When you create a branch, make some commits in that branch, the time you're ready to merge, there is no new merge on the master.

What is another option for merging in git?

Using git rebase Instead of git merge. Using the "git merge" command is probably the easiest way to integrate changes from one branch into another. However, it's not your only option: "git rebase" offers another, slightly different way of integration.

Which strategy is used by git for merging two branches?

octopus - This resolves more than two-head case, but refuses to do complex merge that needs manual resolution. It is primarily meant to be used for bundling topic branch heads together. This is the default merge strategy when pulling or merging more than one branches.

What is the difference between fast forward and 3 way merge?

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.


1 Answers

TL;DR: -s is for specifying a merge strategy -X is for supplying options for said strategy.

The git documentation says:

-s <strategy>
--strategy=<strategy>

Use the given merge strategy; can be supplied more than once to specify them in the order they should be tried. If there is no -s option, a built-in list of strategies is used instead (git merge-recursive when merging a single head, git merge-octopus otherwise).

-X <option>
--strategy-option=<option>

Pass merge strategy specific option through to the merge strategy.

Additionally, further down the chapter MERGE STRATEGIES explains all the available strategies and their options.

like image 145
aPhilRa Avatar answered Oct 01 '22 13:10

aPhilRa