开发者

How to use git am to apply patches from email messages?

开发者 https://www.devze.com 2023-02-12 20:45 出处:网络
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

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 command involved is git am (manual page here).

Please could someone help me get started with git am.


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:

# 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 --to=maintainer@project.com --from=me@here.com ... *.patch

git am will accept the patches created by format-patch, and apply them sequentially, for example:

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.

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.


Patchwork workaround

https://github.com/getpatchwork/patchwork

Since no one seems to know how to convert emails to mbox with readily available tools, many of those cornerstone dinosaur projects projects have an associated, sometimes officially recommended, patchwork instance running, many of them hosted on https://patchwork.ozlabs.org/ e.g.:

  • https://patchwork.sourceware.org/project/gdb/list/ GDB, mentioned on the official contribution guidelines: https://sourceware.org/gdb/wiki/ContributionChecklist#Patch_status
  • https://patchwork.kernel.org/ Linux kernel
  • https://patchwork.kernel.org/project/git/list/ Git
  • https://patchwork.ozlabs.org/project/qemu-devel/list/ QEMU
  • https://patchwork.ozlabs.org/project/gcc/list/ GCC
  • https://patchwork.ozlabs.org/project/glibc/list/ glibc

Patchwork subscribes to the list, and parses the patches generated by git send-email, and allows you to download a patch.

So yes, yet another tooling layer on top of email...

Thunderbird export to mbox

Asked at: What is the easiest way to apply git series of patches from Thunderbird No answer so far.

See also

  • https://unix.stackexchange.com/questions/80519/how-do-i-get-a-linux-kernel-patch-set-from-the-mailing-list
  • How to apply a patch generated with git format-patch?


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.


If the mailing list for the project you want to apply patches from uses public-inbox, which is the case for most Linux subprojects and Git, you can use b4 am tool to download the most recent version of a patch series and pipe it to git am:

b4 am -o- $url | git am

where url is the URL of any message in the thread.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号