git diff for binary Apple property list files
In the same vein as diffing UTF-16 .strings files in git:
It’s easy to set up git
to show diffs for binary .plist
files.
- Add a
textconv
key for this conversion to your~/.gitconfig
:
git config --global diff.plist.textconv "plutil -convert xml1 -o -"
In your global .gitconfig
, it’ll look like this:
[diff "plist"] textconv = plutil -convert xml1 -o -
- Add a mapping from filename to diff command to your project’s
.gitattributes
file:
echo "*.plist diff=plist" >> .gitattributes
- (Bonus points) Set up a global
.gitattributes
file via this Q&A on Stack Overflow to always do this:
git config --global core.attributesfile $HOME/.gitattributes echo "*.plist diff=plist" >> ~/.gitattributes
What this looks like in practice:
% ± file Info.plist Info.plist: Apple binary property list % ± git log -p Info.plist commit 5ba260528509cca6ac9e6a9080543dbfbc7a7561 Author: Christopher Bowns Date: Thu Nov 12 21:42:06 2015 -0800 A new key-value. diff --git a/Info.plist b/Info.plist index 313794c..a619e52 100644 --- a/Info.plist +++ b/Info.plist @@ -2,6 +2,8 @@ >> + ANewKey + IAmAValue CFBundleDevelopmentRegion en CFBundleExecutable