Skip to main content

Patching with GIF DIFF

· One min read

I've recently had the opportunity to work with some remote teams to collaborate on a project. One question that cropped up was how do I pass the project specific changes to the remote team members without committing the credentials to the repository.

The easiest way that I thought of was to create a DIFF file and pass the file to the other members so that they could patch the project prior to deployment to production servers.

The most straightforward way to create a DIFF file is to use git diff. But the question was how can the DIFF file be used to "patch" the project?

Thanks to the (blog post from Thomas Amsler)[], this is easily achieved.

First, create the patch file like so:

git diff --no-prefix > patchfile

This file can then be used as a patch like so:

patch -p0 < patchfile

If the patch was created without --no-prefix, the patch level should be 1 instead:

git diff > patchfile patch -p1 < patchfile