Do local commits often. When the test cases succeed.
Your future self, who will do „just one more tiny change before I close shop for today“, will be grateful.
I mean, go for that tiny change at the end of the day. Just be prepared that it implodes. Then git restore sanity and close.
Avoid the evening session trying to backtrack to the working code you remember having achieved a few hours ago. But, with the night advancing, you begin to doubt you ever really had.
?