# Creating a patch set with git-format-patch

4 messages from 2008-04-10 to 2008-04-10. Participants: Ian Brown, Björn Steinbrink, Sean Estabrooks, Stephan Beyer.
Thread: https://gitlist.dev/t/13045

## Ian Brown, 2008-04-10 08:51

Subject: Creating a patch set with git-format-patch
Message-ID: <d0383f90804100151s6ffde16al6035116c27c9cb3a@mail.gmail.com>
URL: https://gitlist.dev/e/d0383f90804100151s6ffde16al6035116c27c9cb3a%40mail.gmail.com

```
Hello,
  I have a question regarding creating a patch set with git-format-patch:
I had downloaded a git repository of the Linux kernel.

I intend to  make a change in two files: net/ipv4/route.c and
include/net/dst.h and send a
patch set of two patches for review.
Now I want to create this  patch set of two pathces correctly;
First patch for net/ipv4/route.c and second for include/net/dst.h.

what should I do ?

Regards,
Ian

```

## Björn Steinbrink, 2008-04-10 10:56

Subject: Re: Creating a patch set with git-format-patch
Message-ID: <20080410105610.GB29742@atjola.homenet>
URL: https://gitlist.dev/e/20080410105610.GB29742%40atjola.homenet
In-Reply-To: <d0383f90804100151s6ffde16al6035116c27c9cb3a@mail.gmail.com>

```
On 2008.04.10 11:51:59 +0300, Ian Brown wrote:
> Hello,
>   I have a question regarding creating a patch set with git-format-patch:
> I had downloaded a git repository of the Linux kernel.
> 
> I intend to  make a change in two files: net/ipv4/route.c and
> include/net/dst.h and send a
> patch set of two patches for review.
> Now I want to create this  patch set of two pathces correctly;
> First patch for net/ipv4/route.c and second for include/net/dst.h.
> 
> what should I do ?

Just create a branch for you work, then start working and creating
commits. In the end, you'll get one patch for each commit, so group your
work in the commits just as you want it to appear in the patches.

Then, create the patches with:
git format-patch <options> master

That will create patches for all commits that are in your branch, but
not in master. Finally, you can use either git send-email or your
favourite mbox-capable MUA to send the patches.

HTH
Björn

```

## Sean Estabrooks, 2008-04-10 10:56

Subject: Re: Creating a patch set with git-format-patch
Message-ID: <BAYC1-PASMTP020D4804B5CBAC8A5BEBD5AEEC0@CEZ.ICE>
URL: https://gitlist.dev/e/BAYC1-PASMTP020D4804B5CBAC8A5BEBD5AEEC0%40CEZ.ICE
In-Reply-To: <d0383f90804100151s6ffde16al6035116c27c9cb3a@mail.gmail.com>

```
On Thu, 10 Apr 2008 11:51:59 +0300
"Ian Brown" <ianbrn@gmail.com> wrote:

Hi Ian,

> I intend to  make a change in two files: net/ipv4/route.c and
> include/net/dst.h and send a patch set of two patches for review.
> Now I want to create this  patch set of two pathces correctly;
> First patch for net/ipv4/route.c and second for include/net/dst.h.
> 
> what should I do ?

The first step is to edit route.c and commit your change to Git with a complete
description[1].  Then edit the dst.h file and commit that to Git as a separate
change.  Afterward you can use git format-patch to prepare these commits to
be emailed:

$  git format-patch HEAD^^

This tells Git to create a	 text file in the current directory for each commit made
since the reference you pass.   You can then configure git send-email[2] to send
these text files out, or send them manually with your regular email client.  If you
do send them manually, make sure to include the text file inline in your email,
don't send it as an attachment.  You will find a subject line inside the file you can
cut-and-paste into place, and  a few other headers that you'll need to delete.

HTH,
Sean

[1]  Remember that each commit log entry should be made as a one-line overview,
followed by a blank line, followed by as much prose as it takes to fully explain the
change.

[2]  There is a small section about configuring git-send-email for use with gmail
using msmtp here:  http://git.or.cz/gitwiki/GitTips

```

## Stephan Beyer, 2008-04-10 11:55

Subject: Re: Creating a patch set with git-format-patch
Message-ID: <20080410115523.GD8157@leksak.fem-net>
URL: https://gitlist.dev/e/20080410115523.GD8157%40leksak.fem-net
In-Reply-To: <20080410105610.GB29742@atjola.homenet>

```
Hi,

> Just create a branch for you work, then start working and creating
> commits.
> [...]

I've got a further question on that "patch-based" workflow because the 
documentation always stops at "send the patch".

Case 1:
 Assume your patch series get accepted.
 What to do with your local changes branch, say "my-changes"?
 Keeping it would result in a lot of dead branches after a while.

 So, I guess "git branch -D my-changes" is the cleanest way to go,
 but I'm not sure.

Case 2:
 Assume your patch series is not accepted but some patches
 are discussed and need some further work.
 What to do?[1]

 I guess the right way is (after updating master) to rebase--interactive
 the my-changes branch to the master and "edit" every commit that
 need further changes. After the rebase with all changes has finished,
 format-patch and re-send the interesting patches 
 (or format-patch the whole my-changes branch down to master and re-send
  only the changed patches)...

Are my guesses "right" for the two cases? Comments?

Regards,
 Stephan

Footnotes:
  1. Yes, there is step (3) of "An ideal patch flow" in
     http://git.kernel.org/?p=git/git.git;a=blob;f=Documentation/SubmittingPatches
     but it does not suggest steps how to "polish" and "refine".

-- 
Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F

```
