From 63a92cbc29505abfd6686a0af81c2342669f7b7c Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Mon, 23 Dec 2024 15:41:11 -0600 Subject: [PATCH] Add Use External Diff Tool Like Difftastic as a Git TIL --- README.md | 3 ++- git/use-external-diff-tool-like-difftastic.md | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 git/use-external-diff-tool-like-difftastic.md diff --git a/README.md b/README.md index 43d2706..fed6953 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1546 TILs and counting..._ +_1547 TILs and counting..._ --- @@ -383,6 +383,7 @@ _1546 TILs and counting..._ - [Untrack A Directory Of Files Without Deleting](git/untrack-a-directory-of-files-without-deleting.md) - [Untrack A File Without Deleting It](git/untrack-a-file-without-deleting-it.md) - [Update The URL Of A Remote](git/update-the-url-of-a-remote.md) +- [Use External Diff Tool Like Difftastic](git/use-external-diff-tool-like-difftastic.md) - [Using Commands With A Relative Date Format](git/using-commands-with-a-relative-date-format.md) - [Verbose Commit Message](git/verbose-commit-message.md) - [Viewing A File On Another Branch](git/viewing-a-file-on-another-branch.md) diff --git a/git/use-external-diff-tool-like-difftastic.md b/git/use-external-diff-tool-like-difftastic.md new file mode 100644 index 0000000..1f1b082 --- /dev/null +++ b/git/use-external-diff-tool-like-difftastic.md @@ -0,0 +1,23 @@ +# Use External Diff Tool Like Difftastic + +Assuming we already have a tool like `difft` +([difftastic](https://difftastic.wilfred.me.uk/introduction.html)) available on +our machine, we can use it as a diff viewer for the various `git` commands that +display a diff. + +This requires a manual override which involve two pieces — an inline +configuration of `diff.external` specifying the binary of the external differ +and the `--ext-diff` flag which tells these commands to use the external diff +binary. + +Here is what `git show` looks like with `difft`: + +```bash +$ git -c diff.external=difft show --ext-diff +``` + +Without the `--ext-diff` flag, it will fallback to the default differ despite +`diff.external` being set. + +See `man git-diff` and friends for the `--ext-diff` flag. See `man git-config` +for `diff.external`.