git cherry pick – range of commits and exclude some in between

You can specify multiple ranges:

git cherry-pick A..B C..D E..F

or even specific commits:

git cherry-pick A B C D E F

If you have lots of commits you want to exclude, it might be easier to do something like this (sort of like a poor man’s git rebase -i for git cherry-pick):

git log --pretty=oneline A..F | tac > tempfile.txt
< edit tempfile.txt to remove the commits you don't want >
git cherry-pick $(awk '{print $1}' tempfile.txt)

Edit: Added recommendation to tac the log, since git cherry-pick wants to see the commits in the opposite order from what git log produces (could also use git log --reverse ...).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)