Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the easiest way to apply git series of patches from Thunderbird

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.

like image 498
lzap Avatar asked Oct 17 '11 13:10

lzap


People also ask

How do I git patch?

In order to create Git patch file for a specific commit, use the “git format-patch” command with the “-1” option and the commit SHA. In order to get the commit SHA, you have to use the “git log” command and look for the corresponding commit SHA.

Which command is used to create a patch for new commit?

If you want to create a patch for a specific commit, then use COMMIT_ID with the format-patch command.

Why is git apply skipping patch?

A patch is usually skipped when the changes it contains were already applied in the past. There are many possible reasons for this: a merge, a cherry-pick, changes operated manually or using another patch etc.


1 Answers

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.

like image 199
larsks Avatar answered Oct 20 '22 04:10

larsks