I normally use the following git command to cherryppick a range of gerrits..no how do I exclude a couple gerrits in between.. can the below command be modified or is there one where we can pick a range of gerrits and exclude the ones we want..
git cherrypick fromgerritSHA1..togerritSHA1
The thing is if you are cherry picking a range of commits, it will cherry pick the parent commits correctly but then when it hits a normal commit, it fails and says commit is not a merge.
The easiest way to cherry-pick a commit is to use the “cherry-pick” command with the commit hash. In order to cherry-pick changes, you will need to identify your commit hashes.
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 ...
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With