Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cherry pick a list of patch in review Gerrit

Tags:

gerrit

I have a list of patch in review on Gerrit (31 patches that follow each other), and would like to know how to pull them all at once on my local git.

I know it is possible to download a patch though the graphical interface:

Checkout: git fetch <url> refs/changes/78/141978/9 && git checkout FETCH_HEAD
Cherry Pick: git fetch <url> refs/changes/78/141978/9 && git cherry-pick FETCH_HEAD
Format Patch: git fetch <url> refs/changes/78/141978/9 && git format-patch -1 --stdout FETCH_HEAD
Pull git pull <url> refs/changes/78/141978/9
Patch-File 376aeb6.diff.base64  |   376aeb6.diff.zip
Archive tgz | tar | tbz2 | txz

I usually fetch the patch and cherry pick it using the command:

git fetch <url> refs/changes/78/141978/9 && git cherry-pick FETCH_HEAD

But I don't want to do this for all the patches I need.

like image 994
Stoogy Avatar asked Dec 28 '25 19:12

Stoogy


1 Answers

You can use git cherry-pick to get a bench of consecutive patches.

git fetch <url> refs/changes/78/141978/9 
git cherry-pick <first-patch-sha>^..<last-patch-sha>

The fetch command will download the patches from the remote repository and the cherry-pick command will apply the changes from <first-patch-sha> included to <last-patch-sha> included.

like image 82
Elieva Avatar answered Jan 01 '26 23:01

Elieva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!