Using an alternate diff algorithm in Git

后端 未结 3 2138
我寻月下人不归
我寻月下人不归 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:38

    You might try git diff --word-diff instead.

    $ git diff --word-diff
    diff --git a/test.txt b/test.txt
    index 54585bb..a8cd97e 100644
    --- a/test.txt
    +++ b/test.txt
    @@ -1,7 +1,7 @@
    Because git is designed for source code, its diff algorithms {+are bibbity +}
    {+bobbity boo+} treat a line as the minimum indivisible unit. I am trying to edit 
    some markdown files that are word wrapped at column 80. Adding a sentence can 
    cause the rest of the paragraph to be marked as changed.
    
    Is there a way to have Git use a diff algorithm more suited to text? One that 
    treats words or sentences as indivisible units rather then lines?
     No newline at end of file
    

提交回复
热议问题