I'm trying to commit some files in my Git repository, and I'm receiving this error.
This all started when I ran git rm -rf folder
and git rm -rf file
and tried to commit the changes. I've since been able to commit and push without these files being deleted from my remote repository, however I'm now completely stuck.
The full error is:
error: a NUL byte in commit log message not allowed.
fatal: failed to write commit object
What can I do to fix this? My Google-fu has let me down on this one.
Edit:
I've just checked out these deleted files, and attempted to commit again, but it's still giving me the same error. Has my Git repo been corrupted or something?
I've had the same thing happen, for no apparent reason. Tried several things, such as a clean clone, switching from iTerm2 to Terminal... didn't make any difference. I then ended up just going with plain git commit
, after which I manually typed my commit message in the following screen... and that DID solve it. Still not sure what's causing this though, but at least it's solved, sorta.
Seems that for some reason a NULL byte is getting it's way into your commit message, and Git doesn't like that. Try to commit from the command-line and see if that works: git commit -m "My brilliant commit message"
I got this error when i copy some text from a document and paste that text for commit message; so it is due to any invalid character in my commit message; so when i just type manually my code committed easily.
MORAL OF THE STORY: So if you got this error please check your commit message; if there is any return in the of comment message please remove it
I resolved this issue on my end based on Edward Thomson's comment on the question regarding the encoding of the log message. I had a PowerShell script that was invoking Out-File to dump information to a file (happened to be snarfing data from svn logs) that would form the git commit log. Setting the Encoding flag for Out-File to ASCII resolved this issue.
Invoke-Expression "svn log -r $rev $repoPath" | Out-File -Encoding ASCII commit.txt
git commit -F commit.txt
It happens when you copy and paste the log in an editor and a line return conversion happens (\n => \r\n which creates the null bytes for every line return)
Most text editor will handle ignore byte when rendering the text so you will not see it.
Some code editor, like plnkr are smarter so paste the log message on plnkr editor. You will then see the null bytes as error characters. Fix it then use the fixed log for your commit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With