Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: "Warning: Changing a readonly file"

When I go to commit changes to a branch using,

git commit -a

vim is opened and I go to insert my commit message. I get this warning in the terminal:

W10: Warning: Changing a readonly file

In order to continue with the commit, I have to force write using :x! in vim, but otherwise, no problems are encountered.

At the least, this is seems to be just an annoyance. Does anyone know what's going on and/or how to fix this?

I am using Cygwin on Windows 7.

like image 201
kevlar1818 Avatar asked Jun 12 '12 14:06

kevlar1818


2 Answers

If the file .git/COMMIT_EDITMSG exists and is read-only, the simplest thing to do is to delete it - git will recreate it as necessary.

like image 197
ecatmur Avatar answered Oct 12 '22 14:10

ecatmur


Deleting the file didn't fix it for me. Manually setting the core.editor configuration did. After running this command the problem went away for me.

git config --global core.editor "vim"

I do not know why, but this is what finally resolved the issue. $EDITOR was set to "vim" previously and core.editor was undefined before this fix.

like image 43
Wulfhart Avatar answered Oct 12 '22 16:10

Wulfhart