I have a minimized JSON file in my git tree. It is a bunch of data on a single line, without spaces.
Diffs for this file are not very useful, any change in the data, of course, results in the whole line being changed.
I'd like to be able to optionally tell git to diff not the file itself, but output of a pretty-printer (like python -mjson.tool
or jq .
) for that file.
Right now I'm using this command:
diff -u <(git show HEAD:file.json | jq .) <(jq . < file.json)
What is the proper way to do this?
Best Answer
I would set up a git textconv filter for the affected file(s).
In .gitattributes, set the diff tool:
And in .git/config:
json_pp
is present in the Git for Windows distribution, and I had more luck with this than withjq
.