How to generate patches with git format-patch

From OpenHatch wiki
Jump to: navigation, search

git-format-patch prepares e-mail-ready version of patches. In its basic invocations, it will create a .patch file per commit, of the form 000X.First_line_of_commit_message.patch, where X is the number of the commit in the commit series.

Here's an example of using git-format-patch with OpenHatch:

  1. Add a commit on your development branch
    oh-mainline$ git branch
    * Issue-#344
    oh-mainline$ touch new_file
    oh-mainline$ git add new_file
    oh-mainline$ git commit -m "Test commit"
  2. Generate a patch using git format-patch
    oh-mainline$ git format-patch master

What git format-patch master does is look at the commits between master and your current branch, in this case Issue-#344, and create a patch file per commit. git format-patch master..Issue-#344 means the same thing: make patches for the commits between master and Issue-#344. has full documentation on git format-patch.

[edit] See also

Personal tools