Skip to content

Instantly share code, notes, and snippets.

@Radon8472
Created August 20, 2020 10:07
Show Gist options
  • Save Radon8472/c4d2c6563de91fcab2854b1bf384932e to your computer and use it in GitHub Desktop.
Save Radon8472/c4d2c6563de91fcab2854b1bf384932e to your computer and use it in GitHub Desktop.
Export multiple patches
#
# exports multiple patches for a commit-range
# you can choose to select only commits matching a specific sub_dir
#
# usage: export-git-patches [commit_range] [sub_dir]
#
if [ $# -gt 1 ]; then
commit_range=$1
commit_path="$2"
echo 1
else
commit_range=$1
fi
# check if commit_range is empty
if [ -z "$commit_range" ] ; then
commit_range=HEAD
fi
n=0
git rev-list --reverse $commit_range -- $commit_path | while IFS=$'\n' read -r commit_hash
do
n=$((n+1))
# export one patchfile for each line
git format-patch --start-number=$n -1 $commit_hash
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment