This has been resolved. The cause has nothing to do with MATLAB (although it is more likely to happen if MATLAB Project is used within the repo). It is caused by Google Drive or OneDrive desktop integration as described here:
The problem boils down to a race condition where Git creates and modifies files rapidly and the storage solution trying to keep up. In some scenarios this can lead to file IO not behaving as Git expects. A storage solution might also erroneously restore a file that was meant to be removed. While these sort of issues are most likely to occur when you're sharing the repository with other people we've seen issues with people who only use the storage for backup purposes.
Fix: Pause the background sync when you are working with MATLAB.
I hope this helps somebody in the future!