Skip to content

Instantly share code, notes, and snippets.

@stokito
Last active May 5, 2026 09:52
Show Gist options
  • Select an option

  • Save stokito/434a129e4758489577502597c0a8c42b to your computer and use it in GitHub Desktop.

Select an option

Save stokito/434a129e4758489577502597c0a8c42b to your computer and use it in GitHub Desktop.
git: create a single patch file with multiple commits
# last three commits
git format-patch -3 --stdout > multi_commit.patch
# all commits that are in your branch and not in master into a single patch file multi_commit.patch
git format-patch --signoff master --stdout > multi_commit.patch
# create patches in the folder ~/output/directory/ for all commits that are in your branch and not in master
git format-patch -o ~/output/directory/ --signoff master
@mirfaisal-sw

Copy link
Copy Markdown

Hi,
Can you please let me know the use of "--stdout" here?

@stokito

stokito commented Jun 27, 2023

Copy link
Copy Markdown
Author

Execute git format-patch --help to see help. Here is description:

By default, each output file is numbered sequentially from 1, and uses the first line of the commit message (massaged for pathname safety) as the filename. With the --numbered-files option, the output file names will only be numbers, without the first line of the commit appended. The names of the output files are printed to standard output, unless the --stdout option is specified.

@SunaMadhu16

Copy link
Copy Markdown

Hi,
Can you please let me know what is the solution for this below fatal message
$ git am Patches/0002-This-is-second-commit.patch
fatal: previous rebase directory .git/rebase-apply still exists but mbox given.

@stokito

stokito commented Feb 16, 2024

Copy link
Copy Markdown
Author

you din't applied or committer the first patch

@SunaMadhu16

Copy link
Copy Markdown

applied

@stokito

stokito commented Feb 16, 2024

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment