Consider the highlighted commits in the following :

For the current discussion I’ll refer to the commits as follows :
Commit 1 : Read Language settings from the User Settings
Commit 2 : [POC] Do not review
We use Gerrit for code review. Both Commit 1 and Commit 2 are under review and have not been merged. I am working on Commit 1 which required code in Commit 2 and hence had to be based off it. These are the commands I used :
-
Cherry Pick Commit 2. I use the cherry-pick command that get from Gerrit for that change:

-
Make the changes that were needed for my work and push a change which became Commit 1. When I first pushed Commit 1, it was based on patchset 8 of Commit 2.
As and when I get review comments on my commit (Commit 1), I push new patch sets for it on Gerrit. However, when it is to be merged finally, it needs to be on the latest patchset of it’s parent (Commit 2). The way I do it now is as follows :
- git checkout working2
- git reset –hard remotes/origin/head
- Cherry-pick Commit 2 —> This gets me the latest version of Commit 2
- Cherry-pick Commit 1
- git push origin working2:refs/for/head
Is there a way in which I can just get the latest patchset of Commit 2 without doing all of the above ? Perhaps some kind of interactive cherry pick or rebase ?
You can simply rebase Commit 1 to the FETCH_HEAD. While on working2 branch,
Remove the line with the commit message of Commit 2 (first line usually). Now Commit 1 will be on top of the latest Commit 2. If you’re unfamiliar with interactive rebase, take a look here.