いろいろ備忘録日記

主に .NET とか Go とか Flutter とか Python絡みのメモを公開しています。

git difftool で1ファイルずつじゃなくてまとめて差分を確認する (-d, --dir-diff)

概要

知らなかったので、忘れないうちにメモメモ。。。

以前の記事で以下のように WinMerge とか Beyond Compare を設定するやり方は記載していました。

(今はVSCodeとかがデフォルトで設定されるので、そのままでもいいと思います。最新版で3-way mergeにも対応したみたいなので)

devlights.hatenablog.com

devlights.hatenablog.com

設定したら、 git difftool ってすると、アプリが起動して差分みせてくれるので便利!なのですが

1ファイルずつになるので、若干面倒でした。

-d (--dir-diff) オプションを指定

-d というオプションがあって、ヘルプ見ると

$ git difftool -h
usage: git difftool [<options>] [<commit> [<commit>]] [--] [<path>...]

    -g, --gui             use `diff.guitool` instead of `diff.tool`
    -d, --dir-diff        perform a full-directory diff
    -y, --no-prompt       do not prompt before launching a diff tool
    --symlinks            use symlinks in dir-diff mode
    -t, --tool <tool>     use the specified diff tool
    --tool-help           print a list of diff tools that may be used with `--tool`
    --trust-exit-code     make 'git-difftool' exit when an invoked diff tool returns a non-zero exit code
    -x, --extcmd <command>
                          specify a custom command for viewing diffs
    --no-index            passed to `diff`

-d, --dir-diff perform a full-directory diff って書いてあります。

なので、このオプションを指定すると、纏めて一気に差分がアプリ側で確認できます。

$ git difftool -d

とても助かる。

参考情報


過去の記事については、以下のページからご参照下さい。

サンプルコードは、以下の場所で公開しています。