Patching Release branches with Git
Feb 2, 2023
Huy Le
1 minute read

Given two branches master and personal. You made some changes in your personal branch, and because the changes are very personal, you cannot create an Merge Request and push it to the public master branch. So you need to create a patch file that you can apply to master whenever it gets updated.

Create a brand new branch

git diff master personal > ../master-personal-patchfile
git checkout patched master # checkout new branch from master
git apply ../master-personal-patchfile

Create a patch for your personal branch, and apply it to your personal branch

git checkout personal
git diff personal master > ../personal-master-patchfile
git apply ../personal-master-patchfile

For koreader, I have personal changes in the plugins, so whenever there is a release, I create a separate branch for house the release. Then create a patch from dev to release

git diff <official-release> <personal> > ../official-personal-patch
git checkout official-release-patched official-release
git apply ../official-personal-patch