How do I view 'git diff' output with my preferred diff tool/ viewer?

后端 未结 26 2249
清酒与你
清酒与你 2020-11-22 03:20

When I type git diff, I want to view the output with my visual diff tool of choice (SourceGear \"diffmerge\" on Windows). How do I configure git to do this?

26条回答
  •  深忆病人
    2020-11-22 03:55

    If you happen to already have a diff tool associated with filetypes (say, because you installed TortoiseSVN which comes with a diff viewer) you could just pipe the regular git diff output to a "temp" file, then just open that file directly without needing to know anything about the viewer:

    git diff > "~/temp.diff" && start "~/temp.diff"
    

    Setting it as a global alias works even better: git what

    [alias]
        what = "!f() { git diff > "~/temp.diff" && start "~/temp.diff"; }; f"
    

提交回复
热议问题