Better yaml diffs
2023-01-25
I often find myself doing "yaml engineering" and a big part of it consists of diff-ing yaml files.
Using a dyff
, a custom diff tool aware of yaml semantics, is useful, especially when dealing with auto-generated files that are semantically identical but have textual differences (e.g. due to different field order).
I ran these commands to set dyff
as the driver for yaml
files in a specific repo:
1 git config --local diff.dyff.command 'dyff_between() { dyff --color on between --omit-header "$2" "$5"; }; dyff_between'
2 echo '*.yaml diff=dyff' >> .git/info/attributes
The same config can be applied globally too with:
1 git config --global diff.dyff.command 'dyff_between() { dyff --color on between --omit-header "$2" "$5"; }; dyff_between'
2 echo '*.yaml diff=dyff' >> $HOME/.config/git/attributes