Git and MAT files

Hi,
I'm using Git to manage a large number of small MAT files. To minimize the possibility of data loss, I always save all objects, even though most of them will not have changed. However since Git recognizes that the file has changed (due to the 'Platform/Created on' tag), a long list of changed files is presented when selecting them to be staged.
What possibilities exist to change Git's behaviour in such a way that it only shows the files as modified that have changes in their data?
Kind regards, Moritz

3 个评论

Note: .mat files contain a timestamp of when they were created, so files with identical content will not be binary identical. In cases where it was known that the same variables occur in the same order, ignoring about the first 70 bytes of the .mat and comparing the rest might work. But if the order differs then binary comparison will fail for identical variable content.
is anybody aware of a git solution to ignore the first 70 bytes for comparison? Some pre-commit hook?
Do you absolutley need to use small MAT files to save your data? Consider transitioning your program to save the data as text, because GIT is better designed to work with text files, and you won't need to deal with changes in the header that are currently causing your issue. When trying to save objects of a matlab class, I usually just write my own "export to text file" method, and then provide an "import from text file" static method to load it back with the appropriate data.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Git in MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by