Creating and Applying Patch in Git
I’m using the 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 originally created to apply emailed patches.
References
Subscribe to my newsletter
Read articles from Erdal TAŞKESEN directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Erdal TAŞKESEN
Erdal TAŞKESEN
Hey, y’all 🖖🏽 I am a passionate self-taught developer, open-source advocate, and tech enthusiast with a hands-on approach to problem-solving and an unending thirst for knowledge. Anything and everything classified as technology fascinate me.