如何应用使用git format-patch生成的补丁? [英] How to apply a patch generated with git format-patch?
问题描述
在一个git仓库中,如果我执行 git format-patch 1
,我该如何将这个补丁应用到其他版本库?
注意:您可以先预览你的补丁将做什么:
首先统计:
git apply --stat a_file.patch
然后执行干运行来检测错误:
git apply --check a_file.patch
最后,您可以使用 git am
来应用您的补丁:它允许您签署应用的补丁。
这可以是用于以后参考。
git am --signoff< a_file.patch
查看本文中的例子:
在你的git log中,你会发现commit信息包含一个Signed-off-by标签。这个标签将被Github和其他人读取,以提供有关如何提交最终在代码中的有用信息。
I have 2 git local repositories both pointing to the same remote repository.
In one git repository, if I do git format-patch 1
, how can I apply that patch to the other repository?
Note: You can first preview what your patch will do:
First the stats:
git apply --stat a_file.patch
Then a dry run to detect errors:
git apply --check a_file.patch
Finally, you can use git am
to apply your patch: it allows you to sign off an applied patch.
This can be useful for later reference.
git am --signoff < a_file.patch
See an example in this article:
In you git log, you’ll find that the commit messages contain a "Signed-off-by" tag. This tag will be read by Github and others to provide useful info about how the commit ended up in the code.
这篇关于如何应用使用git format-patch生成的补丁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!