Skip to content

Instantly share code, notes, and snippets.

@SeanSobey
Last active November 4, 2022 08:57
Show Gist options
  • Save SeanSobey/a9b3d5b184046336e004ac7ee13b8d85 to your computer and use it in GitHub Desktop.
Save SeanSobey/a9b3d5b184046336e004ac7ee13b8d85 to your computer and use it in GitHub Desktop.
Git to diff zip (or any compressed) files. See this (https://tante.cc/2010/06/23/managing-zip-based-file-formats-in-git/) article.
*.[7z,xz,bzip2,gzip,tar,zip,wim,ar,arj,cab,chm,cpio,cramfs,dmg,ext,fat,gpt,hfs,ihex,iso,lzh,lzma,mbr,.msi,nsis,ntfs,qcow2,rar,rpm,squashfs,udf,uefi,vdi,vhd,vmdk,wim,xar,z] diff=archive
[diff "archive"]
textconv = 7z -so e
binary = true
@pimlottc-gov
Copy link

pimlottc-gov commented Jul 17, 2019

This doesn't seem to do anything for me when I git diff in a repo with tracked zip files, how is it supposed to work? I can't find anything in man git-config about this syntax of including a file extension in a [diff] stanza.

@SeanSobey
Copy link
Author

SeanSobey commented Jul 18, 2019

Sorry forgot to add the (project level) .gitattributes config. (You can make a global .gitattributes file).
Updated the gist (also removed the superfluous git-lfs config).
This also assumes you have 7z installed.

@1kastner
Copy link

Thanks @SeanSobey for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment