Every now and then, as I am dutifully crafting a nice, descriptive commit message, I get an error:
".git/COMMIT_EDITMSG" 81L, 2108C written
error: There was a problem with the editor 'vim'.
Please supply the message using either -m or -F option.
Note this is usually after :wq. I check the .git/COMMIT_EDITMSG file and it has no changes in it. Is there another place that git saves this message to so I might recover it and try committing again? Do people have experience with this problem and know why it might be happening to me? I have no issues writing to other files and permissions seem to be in order.
Not sure as far as git on the COMMIT_EDITMSG when you’re at this state. As mentioned earlier, you may be able to see if vim saved it. But my understanding is that vim’s default is to delete the backup unless you’ve explicitly told it to keep them. In addition, if you didn’t want to have these files scattered all over your directories, you can specify a directory to put them in (you may have to manually create the directory first).
Try adding the following two lines to your ~/.vimrc file:
Manually create the ~/.vim/backup directory, then edit a file and exit. You should see a copy of the file with a “~” at the end of the name in your backup dir.
On a side note, if you’re as lazy as I am, use “:x” to exit vim instead of “:wq”. The “:x” does both a write and a quit.