Hacker News new | ask | show | jobs
by da39a3ee 993 days ago
No, it is not a misconception. How do I apply a patch from gmail to a specific git repo on my computer? (I would genuinely like to know the answer, but it must not involve mutt, gnus, or dovecot!)
4 comments

Save the email to your local machine (in gmail, click the 3 dots and choose download message). Then run

    git am < saved_email_file.eml
Right, thanks! (And using clipboard and stdin sounds even more convenient for small patches as a sibling comment suggests.)
Copy-paste may not work depending on how the email client renders the email. For example, if the email client doesn't preserve prefixed whitespace, then the resulting patch may be corrupted or not apply. Saving the actual email to a file on disk would avoid that issue.
Copy the content of the email to your clipboard, type `git am` in your terminal, paste and C-d to complete.
OK thanks, that sounds fairly convenient for small patches. And I expect you'd say download the email for larger patches (as a sibling commenter suggests).
In the worst case you can copy paste a patch into a new local file in the repo and then apply it with git from there. I’ve had somebody slack me patches before and it is not a big lift.
Many local mail clients also just let you pipe the message into a command; for example, in mutt, you could just type:

   |git am
once you have the message open.
You may have a skewed idea of “most” here.

Most people are using gmail, but when it comes to local clients, Outlook, Apple Mail and Thunderbird are by far the most common and as far as I know none of them support this without extra steps.