1 min read

Managing my hotfixes with patches

Managing my hotfixes with patches

I have had to do a few hotfixes whilst a deploy is not possible, to ensure the bug is fixed as quickly as possible. We have the fix commited but want to manage what is on production for the moment. In come patches!

Now at a glance patches are pretty easy, but when you go from a git environment to an unmanaged environment it can become a bit of a mess trying to find the right information.

Generating a patch for a specific commit

This command will generate a patch for that commit, so ignoring the state of HEAD right now, we just want what was committed there.

git show --patch <commit-hash> >> patches/<patch_name>

Applying the patch to the server

You need to make sure patch is installed, but that's it. Note that we are passing the patch as stdin. For some reason feeding the file as a parameter does not work as expected, it seemed to lock up for me. Additionally the -p1 was just a recommendation to skip the patch headers, containing author information.

patch -p1 < <patch_name>