Submit new/fixed code to an existing Gerrit branch after review
-
14-11-2019 - |
Question
How do I submit a new 'Patch Set' to an existing Gerrit branch that's been reviewed? When I log into the review website, I am given a chance to copy checkout/pull/cherry-pick and patch commands..
I tried the checkout command to get the code into my local workspace:
git fetch http://website/project refs/changes/##/####/# && git checkout FETCH_HEAD
git checkout -b my_new_branch
Then I made changes to the files then I added the local files to the branch by running
git add <filename>
now to submit them back to the repository, I figured I would need to do a
repo commit -m "message"
repo upload <projectname>
but it was telling me I don't have a branch!! So I tried a
repo start <branch name> <project name>
and that cleared my changes.... back to point A.... what are the PROPER order of commands here :) sorry folks, I am still trying to wrap my head around this whole git system! Blaaah... SVN user here :)
Solution
We are using gerrit without repo so this would be my approach to amend an existing patch after a review:
Checkout the change (the checkout -b is optional but recommended)
# From gerrit web, button "Download->Checkout"
git fetch http://website/project refs/changes/##/####/# && git checkout FETCH_HEAD
# This is a good moment to create a local branch, just in case...
git checkout -b my_new_branch
Fix things, fix commit and push for review. Git will give you a chance to edit the message, remember to keep the Change-Id or add it if you don't have any hook
git add <filename>
git commit --amend
git push http://website/project HEAD:refs/for/<branch_name>
You can get the branch name and Change-Id from the existing Change in the gerrit web interface.
More info: Gerrit Uploading changes