> For the complete documentation index, see [llms.txt](https://yu-sun.gitbook.io/essential-git-for-scientists/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yu-sun.gitbook.io/essential-git-for-scientists/cookbook/formated-patches.md).

# Formated patches

### Rationale

* Export the change in Unix mailbox format
* Can do certain setup so that everytime it's generated, it will be automatically emailed
* Include the diff and commit messages
* One file per commit by default

### Command

* `git format-patch <commit-1>...<commit-2>` for a range of commit
* `git format-patch -l <commit>` for single commit
  * If `-l` is ommited, it will get the range to `HEAD`
* `git format-patch <branch>` for between the diverge point with a different branch to the current `HEAD`
* with `-o <output-dir>` will save the files to a destination
* with `--stdout > output.patch` will save a single file
