Developing and Submitting a Patch

We use a web-based code review system called Gerrit. Using this system, anyone can comment on a proposed change before it is merged to our Git repository. It’s pretty easy to use; the instructions below will get you started.

Create a Gerrit Account

  1. Navigate to
  2. Click sign in on top-right
  3. Select Open ID provider (only Google accounts are enabled)
  4. Select user name
  5. Upload your SSH public key

Configuring Your Git Client to Use Gerrit

Follow these steps once for each MOTECH code repository that you clone.

  1. Get source code

    git clone ssh://<userid>
  2. Set up review branch

    cd motech
    git config remote.origin.push refs/heads/*:refs/for/*
  3. Install change-id generation hook

    scp -p -P 29418 <userid> .git/hooks/

Development Workflow

  1. Checkout to feature branch

    git checkout -b newfeature
  2. Make changes/test/multiple commits

  3. When ready to submit changes: update master, squash commits and merge feature branch

    git checkout master && git pull --rebase
    git merge --squash newfeature
    git gui
  4. Edit commit message using the proper commit message format

  5. Push changes

    git push origin

Submitting Changes (Patch Set) to Incorporate Review Comments

If you’ve received some code review feedback and you’d like to make some changes, follow the steps below to add your changes as a new “patch set” to the existing Gerrit code review.

  1. Checkout patch from gerrit change:
    1. Navigate to<change id>/
    2. Copy pull url under patch set section and run
  2. Make changes

  3. Copy change ID from Gerrit (top section in Gerrit change page)

  4. Amend change ID in commit message

  5. Squash commits

  6. Push changes

Pushing to Remote Branches (Not for Review)

This practice enables developers to share in-progress feature work with others without actually submitting the changes for review.

  1. Use branch namespace dev

    git checkout -b dev/newfeature
    git add . && git commit -m "message"
    git push -u origin dev/newfeature:dev/newfeature
  2. Once done with feature, squash commits and merge with master. Submit for review as mentioned above.