jedediah jedediah - 1 year ago 74
Git Question

git format-patch with a list file instead of numbered files

git format-patch
normally generates patch files named like this:

0001-Something.patch
0002-Whatever.patch


Instead, I want to generate patch filenames with commit messages, but no numbers:

Something.patch
Whatever.patch


and a single file that lists all the patches in the correct order.

I will also need an equivalent
git am
to apply these patches.

Can
git
do this? And if not, how would you do it with scripts or whatever?

Answer Source

On Unix-like systems you can do this to remove an initial number up to the first -:

$ git format-patch  120c547..2b05980  | while read x; do mv "$x" $(echo "$x" | cut -d '-' -f2-); done

You can easily apply such patches with git am as this commands takes both mbox and Maildir - just cp all patches into a directory and tell git am to look for patches in this directory. For example:

$ git am /tmp/patches