【发布时间】:2013-04-06 07:24:59
【问题描述】:
我试过了
git diff 13.1_dev sale_edit > patch.diff
然后我尝试在另一个分支中执行git apply patch.diff,但我得到的补丁不适用。如何从可以与 git apply 一起使用的差异创建补丁文件?
收到的错误:
$ 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
我在 Mac 上试试这个
【问题讨论】:
-
Git 不适合这项工作。您可能会花费数小时尝试应用补丁,因为 Git 无法正确处理空格和行尾。我曾经花了一个多小时尝试应用通过电子邮件发送给我的三行补丁(另见Apply patch to file that's under Git without using Git?)。使用
patch程序。它可以处理空格和行尾,而不会到处乱扔垃圾。