git用diff创建补丁
我尝试过
git diff 13.1_dev sale_edit > patch.diff
然后我尝试在另一个分支中做git apply patch.diff
,但是我得到的补丁不适用。 我如何从差异创建补丁文件,我可以使用Git应用?
收到的错误:
$ 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 apply --ignore-space-change --ignore-whitespace patch.diff
正如“git:补丁不适用”中所述,这可能是由以下原因造成的:
.gitattributes
文件中的用户core.eol
是一种很好的方法(请参阅“提交时的git强制文件编码”) x
')。 这可能会导致您将
git config core.filemode false
设置git config core.filemode false
,然后执行git reset --hard HEAD
(确保您没有未提交的更改,否则它们将丢失)。 您可以将修补程序作为3路合并来应用:
git diff 13.1_dev sale_edit > patch.diff
git apply -3 patch.diff
它应该调出冲突,以便您可以手动解决。 或者你可以使用一行代码,直接将修补程序传送给git应用程序:
git diff 13.1_dev sale_edit | git apply -3
要反转该补丁:
git diff 13.1_dev sale_edit | git apply -3 -R
(注意:这与上面的命令相同,没有创建补丁文件的两个阶段过程)
git help apply
-3, --3way
When the patch does not apply cleanly, fall back on 3-way merge if
the patch records the identity of blobs it is supposed to apply to,
and we have those blobs available locally, possibly leaving
the conflict markers in the files in the working tree for the user
to resolve...
在这里,你必须尝试与你有差异的分支。
git diff 13.1_dev sale_edit > patch.diff yourBranch()
链接地址: http://www.djcxy.com/p/30023.html
上一篇: git create patch with diff
下一篇: git on windows shows modified files all the time, even for newly cloned repo