There really isn’t any fix because git works perfectly with Unity when configured properly.
Best practices involve saving your work and closing Unity before using git.
But if you understand how Unity does and does not flush changes to disk (or at least ALWAYS do a save-project), you can get away with leaving Unity open.
The only thing linking EVERYTHING together in Unity is the GUID assigned to a script or asset. Name is irrelevant. Only the GUID connects it. This GUID is in the meta file.
If you fail to commit metafiles to git, you will never be able to work in Unity. 100% of all meta files and all changes to all meta files must be committed along with the work that triggered it, no exceptions.
In your ProjectSettings, these two things MUST be correct for git:
