Using an alternate diff algorithm in Git

后端 未结 3 2129
我寻月下人不归
我寻月下人不归 2021-02-07 01:44

Because git is designed for source code, its default diff algorithm treats a line as the minimum indivisible unit.

I am trying to edit some mar

3条回答
  •  暖寄归人
    2021-02-07 02:34

    Here is an example of customising this (from this question). As a default, --word-diff assumes a word to be a string of non-whitespace characters. The following command will consider a word consist of one of the following:

    1. A string of alpha-numeric characters and underscores
    2. A single non-character

    The command:

    git diff --color-words --word-diff-regex='[A-z0-9_]+|[^[:space:]]'
    

提交回复
热议问题