In git, how to increase the context for merges?

When merging large changes, git is often hopelessly confused because it does not use enough lines of context. It mixes between the similar ends of two different routines that both end with:

. return 1; . } 

(dots used here to represent blank lines)

When I use 'git diff', I can say -U20 to see 20 lines of context. But can I tell git to use this flag when merging it?

Can the answer be related to merge strategies / options, such as:

 git merge -s recursive -X patience [branch] 
+6
source share
2 answers

As far as I know, there is no way to increase the context lines during the merge. The patience restraining algorithm is supposed to handle your use case better. The git-merge (1) manual page describes this as follows:

With this option, merge-recursive spends a little extra time avoiding discrepancies that sometimes arise from unimportant ones (for example, curly braces from various functions). Use this when branches to be merged wildly diverge.

Since this looks exactly the same as in the situation you are describing, patience seems specifically designed to help you. You can try this on a folding branch, for example:

 git checkout -b temp_merge_branch master git merge --strategy-option=patience other_branch 

If the merge works cleanly, you can quickly forward the main branch with the results. If not, you can simply throw away the temporary branch and look for other alternatives.

+4
source

Use these settings to get patience different with five lines of context:

 git config --global diff.algorithm patience git config --global diff.context 5 

If you often use --color-words , this is also useful:

 git config --global diff.wordRegex '[A-z0-9_]+|[^[:space:]]' 

The first setup requires Git 1.8.2 .

+4
source

Source: https://habr.com/ru/post/919218/


All Articles