Reputation: 6784
I have a situation similar to this question. Currently this command shows me perfectly all the commits I need:
git log --cherry-pick --oneline --no-merges --left-only branchB...branchA
Now, I want to create a patch file with every one of the commits displayed in the above command. How can I do it?
Upvotes: 5
Views: 145
Reputation: 635
Try this. I hope it's not too late.
NUM=1
for commit in $(git log --cherry-pick --no-merges --left-only branchB...branchA --reverse --pretty=tformat:"%H")
do
git format-patch -1 $commit --start-number $NUM
((NUM++))
done
--reverse
forces git-log
to push results in reversed order - from the earliest one to the latest one, "%H"
it's format containing only commit sha1 hash. Hashes are being provided as a single (-1
) commits to create patch from. --start-number
with incrementing value causes creation of patch files in right order.
Upvotes: 2