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 :
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 ?
In fact, cherry picks can even be used to replace rebases.
Change commit message when cherry-picking As a consequence, you may want to change the commit message when cherry-picking. To change the commit message when cherry-picking, use “git cherry-pick” with the “-e” option.
You can simply rebase Commit 1 to the FETCH_HEAD. While on working2 branch,
$ git fetch ssh://[email protected]:29418/management-console refs/changes/26/11926/11
$ git rebase -i FETCH_HEAD
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.
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