After searching for a light and finding quite a few similar questions, none of them seemed to really answer my question (below a list of related questions I found).
I am developing further changes on top of a commit not yet reviewed, but I want to keep the changes separate. When trying to push the new patch for review, I get the error:
! [remote rejected] HEAD -> refs/for/master (no changes made)
Scenario: In my branch I have Commit A (merged) <-- Commit B (cherry-picked/unmerged) <-- Commit C (with recent changes I want to push).
As mentioned, Commit C is dependent of B (but as I want them separate, a squash cannot be done. Also removing B is not an option, as it adds changes not yet present is C).
So when I try to push Commit C for review I get the error message above (I understand that is due to Commit B being below the new Commit C).
My question is: is there a way to send only Commit C up to Gerrit, before Commit B gets merged? Or I really must wait for B to be merged so I can send Commit C up?
Homework:
Gerrit workflow - push single commit to topic branch
Git / gerrit, push remote rejected no changes made
Is there a way to force Gerrit to have all commits in a branch be push to code review?
git - pushing only the top most commit to server
Yes, you can push commit-C based on unmerged commit-B but you can't cherry-pick it because that way you get commit-C based on commit-B' (a different commit which has no changes when compared with original commit-B.
Try this procedure:
Checkout the unmerged commit-B (copy this command from Gerrit > Change > Download > Checkout):
git fetch https://USER@SERVER/a/REPO-PATH/REPO-NAME refs/changes/X/Y/Z && git checkout FETCH_HEAD
Create a branch from commit-B
git checkout -b some-branch
Make commit-C change, commit and push to Gerrit
I think Gerrit will create a change with commit-C based on commit-B from previous change. Be aware that if someone change the original commit-B you will need to rebase your commit-C before it can be merged.
Another option may be to simply combine (squash) both commits into one while you are developing (in a separate change-set from B) and once B is merged you can rebase on top of master which will just leave your unique changes.
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