Skip to content

Instantly share code, notes, and snippets.

@laszlomiklosik
Last active August 29, 2015 14:02
Show Gist options
  • Save laszlomiklosik/a36362ecc8be3b32f1c5 to your computer and use it in GitHub Desktop.
Save laszlomiklosik/a36362ecc8be3b32f1c5 to your computer and use it in GitHub Desktop.
Push a new changeset to Gerrit
# 1. First make sure you copied the Gerrit commit-msg hook (from Gerrit to your local repos .git/hooks folder)
# 2. Make the code changes needed and then stage them using the usual command
git add . -A
# 3. Now commit them using amend and notice that the previous commit message is used but is suffixed with the Change-Id of your previous commit. Make sure you leave that (even if you modify the commit message). Note: modifying the commit message will overwrite the previous one.
git commit --amend
# 4. push your changes for review:
git push origin HEAD:refs/for/master
# You are done. As a variation, instead of committing with amend you can use interactive rebase to squash (combine) multiple commits into a single one. Make sure the the Change-Id remains present in the commit!
Hint: it is also possible to push patch sets from a different branch (it ca be a different branch then the one used initially).
Normally while you wait for the code review to be finished you will start another task and possibly make a few commits to your main work branch. When working on review findings you can create a branch from the commit which was reviewed and push you adjustments from there. To create the branch just execute "git checkout sha1-hash-of-the-commit-under-review" and then "git branch your_new_branch_name" and "git checkout your_new_branch_name" then continue as if you were on your usual branch and push to HEAD:refs/for/master (or use another remote destination branch name)
Besides doing all this manually you might be interested in git-review:
http://www.mediawiki.org/wiki/Gerrit/Tutorial#Installing_git-review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment