Working with your git diffs
diffs are annoying to work with, here’s some tricks:
Ignore whitespace
git diff -w
A recent usage of -w turned a 447 line diff into a 102 line diff, that’s 22% the size.
Filter Diff
filterdiff is a CLI tool to…filter…diffs. It’s mostly good at including/ignoring files, less for the content of the diff
# only show diffs of tsx files
git diff | filterdiff -i '*.tsx'
diff-to-json
From the json-toolkit, it leverages unidiff. This won’t simplify the diff, but it does turn it into json so you can write custom jq scripts to parse the diff.
$ git show | diff-to-json | jq
[
{
"patch_info": [
"commit 0ca9e2407271e2d7c30530427e57c5f7c58b3256\n",
"Author: Tyler Adams <coppero1237@gmail.com>\n",
"Date: Sun Apr 23 01:41:33 2023 -0400\n",
"\n",
" Added installation instructions for JSON Toolkit.\n",
"\n",
"diff --git a/README.md b/README.md\n",
"index 2c7f586.…