本文介绍了git用diff创建补丁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过了

  git diff 13.1_dev sale_edit> patch.diff 

然后我试着做 git apply patch.diff 在另一个分支,但我得到的补丁不适用。



收到的错误:



<$ p $如何创建可用于git的差异文件的补丁文件? p> $ git apply --ignore-space-change --ignore-whitespace diff.diff
diff.diff:9:尾随空格。

diff.diff:10:尾随空格。
函数set_change_sale_date()
diff.diff:12:缩进前的空格。
$ this-> sale_lib-> set_change_sale_date($ this-> input-> post('change_sale_date'));
diff.diff:14:尾随空格。

diff.diff:15:尾随空格。
函数set_change_sale_dateable()
警告:application / controllers / sales.php的类型为100755,预计为100644
错误:修补程序失败:application / controllers / sales.php:520
error :application / controllers / sales.php:补丁不适用
警告:application / language / english / sales_lang.php的类型为100755,预计为100644
错误:补丁失败:application / language / english / sales_lang .php:134
error:application / language / english / sales_lang.php:补丁不适用
警告:application / libraries / Sale_lib.php有100755类型,预计100644
错误:补丁失败:application / models / sale.php:170
错误:application / models / sale.php:补丁不适用
警告:application / views / sales / register.php的类型为100755,预计为100644
错误:补丁失败:application / views / sales / register.php:361
错误:application / views / sales / register.php:补丁不适用

我在Mac上试用此功能


  git apply --ignore-space 

-change --ignore-whitespace patch.diff

正如,这可能是由以下原因造成的:




  • 本地文件系统和远程repo之间的行结尾不同。

    User core.eol in .gitattributes 文件是一种很好的方法(请参阅)

  • 执行位(' x ')。

    这可以引导您设置 git config core.filemode false ,然后是 git reset --hard HEAD (确保您没有未提交的更改,否则它们会丢失)。


I tried doing

git diff 13.1_dev sale_edit > patch.diff

Then I tried doing git apply patch.diff in another branch, but I got patch does not apply. How do I create patch files from diffs that I can use with git apply?

Errors received:

$ git apply --ignore-space-change --ignore-whitespace diff.diff
diff.diff:9: trailing whitespace.

diff.diff:10: trailing whitespace.
    function set_change_sale_date()
diff.diff:12: space before tab in indent.
      $this->sale_lib->set_change_sale_date($this->input->post('change_sale_date'));
diff.diff:14: trailing whitespace.

diff.diff:15: trailing whitespace.
    function set_change_sale_date_enable()
warning: application/controllers/sales.php has type 100755, expected 100644
error: patch failed: application/controllers/sales.php:520
error: application/controllers/sales.php: patch does not apply
warning: application/language/english/sales_lang.php has type 100755, expected 100644
error: patch failed: application/language/english/sales_lang.php:134
error: application/language/english/sales_lang.php: patch does not apply
warning: application/libraries/Sale_lib.php has type 100755, expected 100644
error: patch failed: application/models/sale.php:170
error: application/models/sale.php: patch does not apply
warning: application/views/sales/register.php has type 100755, expected 100644
error: patch failed: application/views/sales/register.php:361
error: application/views/sales/register.php: patch does not apply

I'm trying this on Mac

解决方案

Try a:

git apply --ignore-space-change --ignore-whitespace patch.diff

As mentioned in "git: patch does not apply", this can be caused by:

  • the line endings differing between the local file system and the remote repo.
    User core.eol in .gitattributes file is a good approach (see "git force file encoding on commit")
  • the execution bit ('x').
    That can lead you to set git config core.filemode false, followed by a git reset --hard HEAD (make sure you don't have uncommitted changes, or they would be lost).

这篇关于git用diff创建补丁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 15:48