开发者

Can I change the conflict markers in Git? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Is it possible to easi开发者_运维技巧ly change the default conflict markers in Git?

In Git, when I merge, I get characters like this in my file, marking the conflicted sections:

<<<<<<<
|||||||
>>>>>>>

Is it possible to configure Git to use different characters in place of these?


It's up to the individual merge driver. From man gitattributes(5):

There are a few built-in low-level merge drivers defined that can be asked for via the merge attribute.

text

Usual 3-way file level merge for text files. Conflicted regions are marked with conflict markers <<<<<<<, ======= and >>>>>>>. The version from your branch appears before the ======= marker, and the version from the merged branch appears after the ======= marker.

[…]

Defining a custom merge driver

The definition of a merge driver is done in the .git/config file, not in the gitattributes file, so strictly speaking this manual page is a wrong place to talk about it. However…

To define a custom merge driver filfre, add a section to your $GIT_DIR/config file (or $HOME/.gitconfig file) like this:

[merge "filfre"]
         name = feel-free merge driver
         driver = filfre %O %A %B
         recursive = binary

That is: the "text" merge driver does what you don't like, and cannot be configured as to what symbol to use (though you can configure it to use a bigger number of markers). But you can copy-paste the driver, rename it, replace the symbol with yours, and then configure git to use your driver.


I think you can not change the characters but you could use the tool to resolve the conflicts. Try:

git mergetool


No, the marker characters are hardwired in the git source code. There does seem to be an option to change the marker size, but I don't think that's documented (yet?).

If you're really determined, you could hack the source. (Note that the string ">>>>>>>" doesn't actually appear anywhere; look for references to marker_size.)

If the problem is just that you don't like the current markers, you can always filter the merged file to change it. If you're concerned about the markers conflicting with the content of the file, changing the marker size might address that issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜