git报错”You have some suspicious patch lines“

2009年4月13日星期一

 

解说来源:http://www.dont-panic.cc/capi/2007/07/13/git-on-windows-you-have-some-suspicious-patch-lines/


The cause for this problem is the carriage-return/line-feed problem of Git under Windows/cygwin: The patches contain a trailing line-feed if you edited them with a Windows editor and not strictly inside cygwin. This will trigger the pre-commit hook to fail on patches where the last line of a file has been changed.

原因是:

git认为"回车"和"自动换行"不一样。如果用某些编辑器编辑了后,文件中就会出现line-feed,这就会触发git的pre-commit钩子,对存在line-feed的文件报错。


To solve the problem, you need to edit .git/hooks/pre-commit and comment out the following lines:

if (/\s$/) {
bad_line("trailing whitespace", $_);
}


解决方法:

编辑.git/hooks/pre-commit文件,找到下面这三行

if (/\s$/) {
bad_line("trailing whitespace", $_);
}

注释之(#号注释)


0 评论: