Creating and Applying Patch in Git
05 September 2020I’m using erdaltsksn/blank as a Template for my open source projects. When I make a commit in this repository, I need to apply the same commit to every repository in my account which means lots of repetitive work. But there is a simple solution for this kind of work in Git.
We will create a patch file containing the changes and then import it. This will redo every step to match the changes to the repository as a new commit.
git format-patch -n HEAD~1
The second step is to import the patch. There are a couple of options for that but we’ll use the simplest one.
git am 0001-lets-make-patch-to-our-repo.patch
The am
means “apply (from a) mailbox” because it was created to apply emailed
patches.