Gerrit

Next you need to create an account for Gerrit. To do this navigate to gerrit.wikimedia.org, and click on the Register link in the top right. This will then take you to wikitech.wikimedia.org where you must create your account!

Once you have created an account and logged in you must add an SSH key. Go to your settings (again in the top right) and navigate to “SSH Public Keys“.

To generate a key do the following on your machine:

1

ssh-keygen-trsa-C"example@example.com"

You should then be able to get your key from “~/.ssh/id_rsa.pub” (or the location you chose) and then add it to Gerrit.

Getting the code

Now that you have git and you have added your SSH key to gerrit you can use ssh to clone the code repository onto your local machine. Again you can read docs for this on the git-scm website.

This created a hook file in your .git directory for this repo that will automatically add the Change-Id in the future! To get the Change-Id in your current commit message run:

1

git commit-a--amend--no-edit

And now you are ready to actually push your commit for review!

1

git push origin HEAD:refs/publish/master

You change should now be on Gerrit!

Your master branch is now 1 commit ahead of where master actually is, so to clean up and reset your local repo to the same state as the remote just run:

1

git reset--hard origin/master

You can always get back to your commit by using the hash of the commit with the “git checkout” command. Or you can copy the remote checkout command from the Gerrit UI, it looks something like the below:

Amend the commit (you can add –no-edit if you do not want to edit the commit message):

1

git commit-a--amend

And push the patch again!

1

git push origin HEAD:refs/publish/master

Notes

This post covers the bare necessities for submitting a patch to Gerrit and responding to comments. There are many things it does not cover such as Git, re-basing, drafts, cherry-picks, merge resolution etc.

Also I should point out that Gerrit is going to be disappearing very soon in favour of Diffuision so there may have been little point in me writing this, but someone asked!

If you do not want to use git-review to contribute to Wikimedia or Gerrit projects then the most important thing to raw from this post is the under advertised “git push HEAD:refs/publish/master” command!