Turn Code Reviews into Seamless Collaboration with Git, Email, and PRs
This article explains how to conduct code reviews using email patches, Git commands, GitHub pull‑request workflows, and Alibaba Cloud Codeup, covering patch generation, reviewer signatures, offline review techniques, and server‑side hooks to create a traceable, collaborative development process.
1. Email‑based code review
This loosely coupled model requires every patch to be approved by a benevolent dictator before merging. Developers generate patches with git format-patch and send them via email. git format-patch origin/master..HEAD A typical patch email looks like:
From: Author Name <author@email>
Subject: [PATCH] first line of commit message
more commit message...
---
diff --git ...Subject uses the [PATCH] prefix; the first line of the commit message becomes the title.
The commit message follows a blank line; the end of the message is marked by --- before the diff.
Lines between --- and diff --git are ignored (often statistics or extra notes).
Useful options include --cover-letter for a summary email, -v {num} for versioned patches (e.g., [PATCH v2]), --in-reply-to="{Message-ID}", --to={email}, and --cc={email}.
Apply patches with git am [options...] mail... and send them with git send-email.
2. Converting review snippets to commits
Small fixes can be sent as plain‑text substitutions, for example: s/waring/warning/ Reviewers may embed full patches separated by a “scissors” delimiter (e.g., -- >8 --). The command git am --scissors recognises this delimiter and extracts the patch.
3. Adding contributor signatures
Git records only Author and Committer. Additional contributors are acknowledged with trailer lines such as Signed‑off‑by:, Reported‑by:, Helped‑by:, and Reviewed‑by:. These can be added automatically with git commit -s or git am -s.
4. GitHub pull‑request based collaboration
GitHub uses pull requests for code review. Review comments can contain code blocks that can be turned into commits. Clicking the first button in the comment toolbar inserts a fenced code block.
Users with write access can convert a comment’s code block into a new fix commit, adding an additional commit to the review.
5. Offline review and online sync
For large PRs, developers may fetch the PR locally using special refs, then test offline. Example commands:
git fetch origin refs/pull/123/head
git switch -d FETCH_HEADAfter local changes, they can be pushed back to the review with:
git pr -c 1236. Alibaba Cloud Codeup integration
Codeup allows creating reviews directly from the client without extra branches. Example: git push origin HEAD:refs/for/master/topic1 The helper tool git-repo simplifies the workflow, and git pr can be used to create or update a review.
Codeup also provides a special ref for offline review:
git fetch origin refs/merge-requests/123/head
git switch -d FETCH_HEAD7. Server‑side hooks
The offline‑online workflow relies on Git’s proc-receive hook and the new report-status-v2 capability, contributed by Alibaba and released in Git 2.29.0.
These techniques enable developers to move from “talk is cheap, show me the code” to a robust, traceable code‑review process across email, GitHub, and enterprise platforms.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Alibaba Cloud Developer
Alibaba's official tech channel, featuring all of its technology innovations.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
