Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What situations should the strategy-option flags be used in when doing a git merge? ( patience | minimal | histogram | myers )

I want to get a high quality diff and I am not worried about how long it will take, e.g.

git merge --strategy-option=diff-algorithm=minimal develop

From the docs, Its not clear which one is best for which situations?

  • default, myers The basic greedy diff algorithm. Currently, this is the default.

  • minimal Spend extra time to make sure the smallest possible diff is produced.

  • patience Use "patience diff" algorithm when generating patches.

  • histogram This algorithm extends the patience algorithm to "support low-occurrence common elements".

There is a summary of the patience algorithm in another answer.

  • Is the histogram algorithm always be better than the patience algorithm since it extends it?
  • Is the minimal algorithm better than the default since it 'spends extra time'?
  • Are --strategy-option=patience and --strategy-option=diff-algorithm=patience equivalent?
like image 383
Robert Avatar asked May 23 '14 12:05

Robert


People also ask

Which strategy is used by git for merging two branches?

Recursive. This operates on two heads. Recursive is the default merge strategy when pulling or merging one branch. Additionally this can detect and handle merges involving renames, but currently cannot make use of detected copies.

What merge strategy does GitHub?

When GitHub creates merge commits, like to test whether a pull request can be merged cleanly or to actually merge a pull request, it now uses the merge-ort strategy.


1 Answers

You should always use histogram and not worry about it. The vast majority of the time all algorithms will give the exact same results, but once in a great while there will be an XML file or a heavily edited C file with lots of curly brackets where myers and minimal will merge up meaningless repeated sections of the file and have a completely broken and unusable output with unrelated sections of code on either side of conflict sections. Both patience and histogram will handle those cases fine, but histogram runs faster. Since histogram is both the best and fastest algorithm, there isn't much reason to use anything else.

like image 175
Bram Cohen Avatar answered Nov 15 '22 09:11

Bram Cohen