Learning center

When to send a review as a series of Git patches

Send one patch per commit when the reviewer needs to see the order of a linear change. Put the exact base commit in the handoff so the recipient can recreate the sequence in a fresh review branch and run a check after each step.

Review a refactor before its behavior change#

Suppose the first commit extracts the function that chooses a sensor timeout. The second changes its default. As a single diff, the moved code and new behavior appear together. The recipient wants to run the old timeout test after the extraction and inspect the expectation that changes in the second commit.

git format-patch --base=approved-base -o transfer approved-base..review

In a clean recipient checkout, resolve the recorded base ID and create a branch there. With the example’s two numbered patch files, import the series in filename order:

git switch -c inspect-series <recorded-base-commit>
git am /approved-transfer/0001-*.patch /approved-transfer/0002-*.patch

Inspect or check out each imported commit for the two tests. If a mail gateway wraps lines and git am fails, ask for the original patch files through the approved transfer. Resolving the broken import by hand changes the material under review. Git format-patch and base information · Git am

The import writes new commits. If the decision must reference the sender’s exact commit IDs or a merge commit, use a Git bundle. Git format-patch omits merge commits from its output.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading