Created
September 25, 2018 16:54
-
-
Save Ricket/78bcd681db86bcbb134558428c4c6cb4 to your computer and use it in GitHub Desktop.
git diff -- use jq to pretty-print the json before diffing it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "*.json diff=json" >> ~/.gitattributes | |
git config --global core.attributesfile ~/.gitattributes | |
git config --global diff.json.textconv "jq '.' \$1" |
For those who need faster json parsing because of commits with many json files, I suggest json_xs
instead of jq
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
textconv
already adds the filename as a parameter, so the$1
is not needed and results in the JSON being printed twice. The following should work fine (adding--sort-keys
for reproducible diffs):git config --global diff.json.textconv "jq --sort-keys ."