Last active
March 11, 2023 21:50
-
-
Save michitux/f7fdb2c36e728887b411e9aecb8e52ff to your computer and use it in GitHub Desktop.
Export a series of git commits into patches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspired by http://blog.worldofcoding.com/2013/03/formatting-git-patches-for-partially.html | |
# This calls git log to get a list of commits that affect a certain file pattern and then exports each of them into a file | |
# If the exported commits shall be limited to these files, another pathspec could be added in the second git log call. | |
# The code is split into several lines to make it more readable, but all ";" are there such that all line breaks could be removed. | |
c=0; | |
git log --oneline --reverse -- your/pathspec.* |cut -d' ' -f1 | while read a; | |
do | |
c=$[c+1]; | |
n=$(printf "%04d\n" $c); | |
git log -p --pretty=email --stat -m --first-parent $a~1..$a > $n-$a.patch; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment