I had a weird loss of a git commit when my battery died unexpectedly. I made a commit and actually pushed it to the remote, then was about to deploy when the battery on my aging laptop cut out. When I plugged in and booted back up, everything I thought I had committed was in my stage and there was no commit in the local history, so I assumed I just forgot to commit. I noticed a few tweaks I wanted to make to the staged files, so I made them and committed. Then, when I went to push, I got a message that there was work committed to remote that I did not have locally. After pulling and getting merge conflicts, I realized that the remote commit was in fact the one I remembered from before, being the same as my local commit without the few tweaks. So I had to revert the local commit, stash, pull, pop, then deal with the conflicts to make another commit on top of the original one.
I’m not sure what happened. I would’ve thought that making a commit would be written to disk immediately. Maybe there’s some sort of write cache that collects operations and runs them when it’s more efficient. I do have an older SSD. I’m glad I was able to resolve the loss in this issue, but that does suggest there may be problems in the future as my battery ages.