Quick tip on how to create git patch files in Emacs using Magit.
Table of Contents * Single-file patch * Multi-file patch * More Resources
Recently I came across few instances where people were asking questions related to creating patches for contributions to Emacs and Org mode repos here and then here. I was in the same shoes back then when I was about to make my first contribution to Emacs. And so I thought of sharing this tip on how to use Magit to create patch files.
If you have been using both Emacs and git, you might have already heard about the awesome Magit package. If you haven’t 😲, check out this screenshot-annotated review of what Magit is. With that out of the way, and assuming that you already have it installed
(use-package magit :ensure t)
, here’s how to create a patch file using Magit ..
Single-file patch #
l l to show the log of the current branch.W c c RET.RET selects the commit the point is on, in the
∗magit-log∗ buffer.0001-Update-docstrings-for-shortdoc.el.patch created in
your git repo root.Multi-file patch #
If you need to create a multi-file patch i.e. patch files for a series of commits, select those commits in the ∗magit-log∗ buffer
The commit selection process is the same as how you would select
text in any Emacs buffer. For example, if I want to create a series
of 5 patches, I would go to the latest commit in the series, hit
C-SPC and then C-n 4 times to select 5 rows of commits.
, and then use the same W c c binding.
More Resources #
Here are the official contribution guides for Emacs and Org mode:
Here are some more resources that got shared in the Emacsverse recently (within the past year as of writing this):