Apply Patch的時候後有時候會遇到詭異的問題,明明patch是對的,卻打不上,提示如下錯誤:
Fix patch error "Hunk #* FAILED at * (different line endings)"
有一種可能是Windows和Uinix的文件line ending不同導致的,如果你是工作在Linux上,一個行之有效的解決方法是把Windows格式(dos)的文件轉換爲Unix
$ dos2unix <file_name> #把指定文件轉爲unix格式 $ find . -type f -exec dos2unix {} \; #把當前目錄下所有的文件轉爲unix格式
如果轉化格式後,還打不上patch,可以提交修改之後再試,一般就可以成功了
$ git add . $ git commit -m "<your comment>" $ git am <your_patch>