How to do it...

We'll pretend that we have been working on the develop branch and have made some commits. Now, we need to format patches for all those commits so that we can send them to the repository maintainer or carry them to another machine.

Let's see the commits on develop, not on master:

$ git log --oneline master..develop583225a (HEAD -> develop) Adds functionality to prime-test a range of numbersf6c5713 Adds Makefile for easy buildingd00ffc0 Move print functionality of is_prime

Now, instead of running git format-patch -3 to get patches made for these three commits, we'll tell Git to create patches for all of the commits that are not on the master branch:

$ git format-patch -o not-on-master masternot-on-master/0001-Move-print-functionality-of-is_prime.patch ...

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.