如何使用 git am 从电子邮件中应用补丁?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5062389/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use git am to apply patches from email messages?
提问by DarkKnight
I am pretty familiar with git(the basic stuff atleast-branches, merges,collaboration with peers etc.) but the other day a friend of mine told me that we could use git with our mailbox. The package involved is git-am (manual page here).
我对 git 非常熟悉(至少是分支、合并、与同行协作等的基本内容),但前几天我的一个朋友告诉我,我们可以在邮箱中使用 git。所涉及的包是 git-am (这里的手册页)。
Please could someone help me get started with git-am.
请有人帮助我开始使用 git-am。
回答by Cascabel
The other big thing involved is git format-patch
. This will create the patches to be emailed; they can then be sent using git send-email
or directly. For example:
涉及的另一件大事是git format-patch
。这将创建要通过电子邮件发送的补丁;然后可以使用git send-email
或 直接发送它们。例如:
# create a patch for each commit from origin's master to yours
git format-patch origin/master..master
# now send them...
# there are a zillion options here, and also some configuration; read the man page
git send-email [email protected] [email protected] ... *.patch
git am
will accept the patches created by format-patch
, and apply them sequentially, for example:
git am
将接受由 创建的补丁format-patch
,并按顺序应用它们,例如:
git am *.patch
You'll have to figure out how to export the patches in mbox format from your mail client yourself, though I suppose you could also simply send them as attachments or transfer them directly.
您必须自己弄清楚如何从邮件客户端以 mbox 格式导出补丁,但我想您也可以简单地将它们作为附件发送或直接传输。
You can try this out for yourself entirely within one repository to see how it works. Create a set of patches as above, then check out the starting point, and use git am
to apply the patches.
您可以完全在一个存储库中亲自尝试一下,看看它是如何工作的。如上所述创建一组补丁,然后检查起点,并用于git am
应用补丁。
回答by J-16 SDiZ
You need a mail client that can export mail as mbox file. Export the mails and run git-am your-mbox-file
. It's done.
您需要一个可以将邮件导出为 mbox 文件的邮件客户端。导出邮件并运行git-am your-mbox-file
. 完成。