2010-02-12 88 views

回答

38
git apply name-of-file.patch 
+6

这可能不是已经回答了原具体问题,但它回答标题中的问题,这就是为什么我在本页。谢谢! – 2017-02-01 22:17:36

+0

这是正确的方法 – 2017-07-16 08:50:47

+2

我明白这是一个古老的问题和答案......但我认为这可能会有助于有人了解[git apply和git am之间的区别](https://stackoverflow.com/问题/ 12240154 /什么,是最差的git-AM-和混帐应用间)。 – mgarey 2017-08-23 17:22:59

13

或者,如果你踢它老学校:

cd /path/to/other/repository 
patch -p1 < 0001-whatever.patch 
81

注意:您可以先预览你的补丁会做什么:

首先统计:

git apply --stat a_file.patch 

然后空运行以检测错误:

git apply --check a_file.patch 

最后,您可以使用git am来应用您的修补程序:它允许您签署应用的修补程序。
这对于以后的参考很有用。

git am --signoff < a_file.patch 

看到example in this article

在你的git的日志,你会发现提交信息中包含“参团的off-by”标签。这个标签将被Github和其他人阅读,以提供有关如何在代码中提交的有用信息。

http://assets.ariejan.net/wp-content/uploads/2009/10/imdb_signed_off.jpg

9

如果你想应用它作为提交,使用git am

+0

你通常如何获得mbox文件? – 2018-03-06 03:20:13