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 comentarios

Walter Roberson
Walter Roberson el 30 de Mayo de 2015
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.
Markus Leuthold
Markus Leuthold el 9 de Jun. de 2020
is anybody aware of a git solution to ignore the first 70 bytes for comparison? Some pre-commit hook?
Joe Cosentino
Joe Cosentino el 9 de Jun. de 2020
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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Preguntada:

el 30 de Mayo de 2015

Comentada:

el 9 de Jun. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by