Skip to content

Share patches

Time to read:
2 minutes

Overview

As they are standard text files, patches can be easily shared through a variety of channels.

Modern platforms and workflows will favor pull requests, but you can still find patches very useful to cover specific use cases.

Email workflow

Many projects, including the Linux kernel and Git itself, are using a mailing-list-based workflow:

  1. generate patches from commits using git format-patch command;
  2. use git send-email command to send patches.

I won't dive into details in this tutorial.

Before sending your first email you also need to configure properly the server to use. Check reference of send-email for full details.

Sharing via chat or tickets

Nothing beats a simple file sharing when it comes to simplicity. Just send patch files so receipient and they will be able to apply them on their code.

Limitations

Sharing one or more patch files can appear as an easy way to bypass a full pull-request process and gain time.

But keep in mind some limitations of this process:

  • Binary files: Reading a diff on binary file will be quite challenging for most human. So make sure you only accept such patch from trusted sources for obvious security concerns.
  • Merge commits: Patch files cannot represent merge commits.
  • Context changes: If the target code has diverged significantly, a patch may not apply cleanly.
  • No conflict markers: Unlike a merge, git apply will fail entirely if the patch doesn't fit. There's no conflict resolution that you can handle.