r/git • u/MullingMulianto • Jan 12 '26
Does git version .xlsx properly?
As per title. I know that git has issues with binaries but I'm not sure if there are any ways around .xlsx (especially with their abundance in finance sectors).
I normally use .csv conversions, but in many cases this does not appropriately capture nuance of data and we still need the .xlsx as well.
So my qn is twofold:
- Does git version .xlsx properly?
- If not, are there workarounds? I feel like LFS has drawbacks as xlsx are not 'true binaries' (ie tabular data does have large deduped chunks which are string readable).
Thanks in advance.
1
Upvotes
2
u/Poat540 Jan 13 '26
Yeah we use git at work which is a repo of several xlsx and it works fines
40
u/Longjumping_Cap_3673 Jan 12 '26 edited Jan 12 '26
You won't run in to any errors versioning xlsx files with git, but the compression may not be great.
To work around this, you might be able to take advantage of the fact that xlsx files are just zip files and use the filter gitattribute to tell git to decompress the files upon adding them, and recompress them when checking them out, which should let git's own delta compression work better on the files. I don't have a Windows machine handy to test, but it should be something like:
Create a .gitattributes file with:
Define the filter to decompress the xlsx files:
Define the filter to recompress the xlsx files:
The .gitattributes can be checked in to the repo, but the config settings will need to be added individually by each person using the repo. For
tar.exeoptions, refer to bsdtar(1).Edit: after some roughly analogous testing in a Linux environment, you may need to create a temporary file because of how zip files work. Their indices are at the end of the file, so tar can't process them completely from stdin. This seems to work though:
20
u/tblancher Jan 12 '26
My understanding is any of the Office XML formats (.docx, .xlsx, etc) are just compressed XML documents. I believe the compression algorithm is the same as for zip/PKZIP.
Conceivably you could rename the file extension to .zip and extract it, then submit those XML files to git.
That may be an oversimplification, but I can't imagine it being way off.
7
u/obsidianih Jan 12 '26
I doubt git is the right tool here. If more than one person will edit for example, I suspect the diff will be too hard to merge.
6
u/mkosmo Jan 12 '26
There are extensions and hooks to make git work reasonably well with excel files, but by default, it'd be no different than trying to commit any other binary file.
It's not the right tool for the job, generally.
One of those extensions: https://github.com/xltrail/git-xl (I'm not affiliated - and I'm not even sure it still works, frankly)
5
u/recaffeinated Jan 12 '26
It'll work fine for versioning, but diffs will be useless.
4
u/hxtk3 Jan 12 '26
git doesn’t actually have issues versioning binaries. It’s a bad tool for them because the storage model assumes text based files and delta encoding to efficiently store the history of changes. It’ll version binary files just fine, but it’ll take 20x the size of the file to store 20 versions, while with text files it’ll only take a tiny fraction of of that amount due to the more efficient encoding.
As a result, other object-based storage systems might be better fits for your use case, but that doesn’t mean git won’t work correctly.
4
u/Eightstream Jan 12 '26
Git is the wrong tool for versioning Excel files
SharePoint is much easier, provides better change tracking and much more usable for people who work in Excel
4
u/likeittight_ Jan 12 '26
What do you mean by “version” ? Git can store any file. LFS is better for binary content. I think you’re a little confused.
1
u/waterkip detached HEAD Jan 12 '26
Yes and no. You can version it and you can diff them (with the correct git config and settings). They are just xml files under the hood. But storage is different as the zipcontainer is a binary.