15

I would like to apply a patch sent with git-send-email.

Currently I have to type everything to the specific files.This is a hacky and very slow as my workload is increasing.I would like to know how I could get a fairly large patch into my git tree faster for testing.

Thanks in advance

1
  • Thanks! My exact problem was how to save the patches into a .patch file ;-)
    – nevanom
    Mar 8, 2018 at 16:02

2 Answers 2

12

You can apply patches from email-formatted patch using any raw data viewer.

For example, GMail, in the current interface, has support for it. You can apply a patch as a commit from a mail message following these steps:

  1. Open the GMail web page in the message with patch data
  2. Click at the ellipsis icon located at top-right of this message
  3. Click at "Show Original". A new tab will open with the content of the message.
  4. Click at "Copy to clipboard"
  5. Open a terminal and change current directory to git-based root project directory
  6. Certify that the working copy is clean
  7. Run git am
  8. Paste the code
  9. Type Ctrl-D to finish the insertion

For more information, check:

Kernel Newbies - Applying a patch tutorial

Eletric Toolbox - Gmail view raw message article

4

Check to see if the patch applies without errors:

git apply --check <patchname>

Apply the patch:

git apply <patch name>

Here is a blog post where you can get more info on email patches.

3
  • The patch is the body of the message.Do I copy and paste this as a diff file?
    – nevanom
    May 11, 2014 at 16:21
  • If the code is in the body of the email message take a look at git am May 11, 2014 at 19:39
  • @Aslaville: please select an answer if the issue is resolved. You have 13 questions without any selected answer. Dec 25, 2014 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.