Skip to main content

Command Palette

Search for a command to run...

Creating and Applying Patch in Git

Published
1 min read
Creating and Applying Patch in Git
E

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.

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

  1. https://git-scm.com/docs/git-format-patch