Gerrit: Code Review Built Around Single Commits

Gerrit: Code Review Built Around Single Commits

Gerrit reviews commits, not branches, and that single decision makes it feel unlike every other review tool.

The model

You push a commit to a magic ref and Gerrit creates a change. Reviewers comment. You amend the commit and push again, creating a new patchset of the same change. When approved, Gerrit submits it.

There is no long-lived branch, no merge commit from a feature branch, and no accumulating “fix review comments” commits. History ends up linear and each commit is one reviewed, buildable unit.

A Change-Id trailer in the commit message is what links patchsets together, inserted by a commit hook.

Why large projects use it

Per-commit review scales where per-branch review does not. Android, Chromium, Go, OpenStack and the Qt project all use it, and they share a property: very large codebases with many contributors where a twelve-commit pull request is unreviewable.

Relation chains express dependencies between changes explicitly, so a stack of commits is reviewed in order with each tracked separately. That is a first-class concept here and an afterthought in most forge tooling.

Why most teams do not

The workflow is genuinely unfamiliar and the interface is dense. Developers accustomed to Gitea, Forgejo or GitLab pull requests find amending commits and force-pushing counterintuitive, and our git branching guide describes the model they are used to.

For a team of five on a normal application, the overhead is not repaid. Gerrit earns its place when review quality on individual commits actually matters.

Our git hooks post is relevant here: Gerrit’s commit-msg hook inserting the Change-Id is one of the few hooks nearly everyone installs.

Operational notes

A Java application with its own git storage, backed by H2 for small installs or an external database. Review data lives in git itself as NoteDb, which means the reviews are in the repository rather than only in a database.

Operational caution

Access control is per-project, per-ref and expressive, which also means misconfiguration is easy. Verify that refs/for/* permissions are what you intend before onboarding people.

Back up the git repositories and the All-Projects and All-Users meta repositories; the latter hold configuration and account data.

License

Gerrit is released under the Apache License 2.0.