What is the easiest way to apply git series of pat

2019-04-08 03:08发布

I have a mail with N attachments in the 000X-xxxx.patch format. I would like to apply all the patches on top of my master, but I would like to have all the commits separate, as the original author commited them. Including the commit message of course.

Method 1: Open the email, click Save as, xxx.eml and then:

git am xxx.eml

The result is ok, but everything is squashed into one commit. Not acceptable.

Method 2. All the attachments are saved in a directory, then:

git am 000*.patch
Patch format detection failed.
git apply 000*.patch
(does nothing)

This is not working. Advices? Thanks.

2条回答
ら.Afraid
2楼-- · 2019-04-08 03:27

Reading through the git am man page, it looks like the commit message is formed from the Subject: line and the message body, which means that you're not going to be able to recreate the original sequence of commits (that is, there's no means by which to recover the commit message the author used for each individual commit)...although according to the man page, git am is meant to work with inline patches, not patches included as attachments, so I'm surprised it's doing the right thing even in method 1.

If you're willing to discard the commit messages, you should be able to save the patches to individual files and just git apply ... them in sequence.

查看更多
Viruses.
3楼-- · 2019-04-08 03:35

As far as I have been able to find, Thunderbird does not have a sensible way to save several emails as individual files at the same time. You can save them one at a time, though, and this does work for small patch sets.

Ironically, I accidentally discovered the easiest way by sending Linux patches to a colleague who doesn't follow the mailing lists. Forward them To yourself (as attachments).

  1. Select all the patch emails
  2. Forward them to yourself as attachments
  3. Save all attachments to an appropriate directory
  4. apply the emails. e.g "git am my_patch_dir/[PATCH -v5*"
查看更多
登录 后发表回答