让Git自动在Markdown文件上使用--word-diff

时间:2017-04-26 09:34:53

标签: git markdown diff

在撰写Markdown(文章,报告,文档等)时,在差异化时使用--word-diff标志会更有用。

如果没有--word-diff,我们会看到整行的变化:

-Luckily, Git commit templates are incredibly simple to set up. Start by creating
+Luckily, Git commit templates are relatively simple to set up. Start by creating

使用--word-diff,我们发现只有[-incredibly-]{+relatively+}发生了变化:

Luckily, Git commit templates are [-incredibly-]{+relatively+} simple to set up. Start by creating

我真的希望Git在知道我正在分析Markdown文档时自动使用--word-diff:这可能吗?我开始松散地阅读Git属性,但没有快乐。

干杯!

1 个答案:

答案 0 :(得分:0)

在命令行上似乎没有简单的方法可以执行此操作,但您可以将参数添加到命令中,或在项目中设置--word-diff配置,或全局设置。我在〜/ .gitconfig中有一个别名:

[alias]
    df = diff --patch-with-stat --word-diff --find-renames
    dfs = diff --staged --patch-with-stat --word-diff --find-renames
    # more aliases

还有一个与How to automatically use git diff --word-diff option for *.tex files but not others?相关的答案。