Skip to content

Diff command

Muhammet Şafak edited this page May 27, 2026 · 1 revision

commitbrief diff <args...>

Run a review against an arbitrary git diff. The positional arguments are forwarded verbatim to git diff --no-color --no-ext-diff <args>, then the resulting unified diff feeds the same review pipeline as --staged / --unstaged.

Replaces the v0.x --commit, --branch, and --pull-request scope flags (folded into this single subcommand in v0.9.0).

Synopsis

commitbrief diff <args>...

At least one positional argument is required (cobra.MinimumNArgs(1)). Any number of args past the first is accepted and passed through to git, which allows e.g. commitbrief diff main -- '*.go' (pathspec after --).

Common forms

Invocation Equivalent git command What it reviews
commitbrief diff HEAD git diff HEAD Working tree vs HEAD.
commitbrief diff HEAD~3 HEAD git diff HEAD~3 HEAD The last three commits' net change.
commitbrief diff main feature git diff main feature One branch vs another (working-tree-style).
commitbrief diff main...feature git diff main...feature Three-dot range — feature's changes since branching off main (PR style).
commitbrief diff <merge-sha> git diff <merge-sha> First-parent diff of a merge commit. No special warning.
commitbrief diff HEAD -- '*.go' git diff HEAD -- '*.go' Filter by pathspec after --.

Anything that git diff accepts works — the subcommand does not parse the arg list at all.

Filters on top

The global --file / --dir flags layer on top of the git-side pathspec. They are applied after the diff is parsed:

commitbrief diff HEAD~3 HEAD --dir docs/
commitbrief diff main...feature --file src/main.go

Pipeline

Identical to the default Review command once the diff is in hand — same ignore filters, same guards, same provider call, same renderers. Only the diff source changes.

Differences from --staged / --unstaged

  • diff always shells out to git diff (the internal/git CLI fallback). It does not go through go-git.
  • diff does not honor --staged / --unstaged — those flags are for the bare-command review path, not subcommands.
  • The merge-commit warning that earlier versions printed on --commit <merge-sha> is gone (v0.9.0+). commitbrief diff <merge-sha> follows git's first-parent semantics with no nudge.

Examples

# Review the working tree against HEAD.
commitbrief diff HEAD

# Review the last 5 commits combined.
commitbrief diff HEAD~5 HEAD

# Review a feature branch as if it were a PR against main.
commitbrief diff main...feature

# Restrict a PR-style review to Go files only.
commitbrief diff main...feature -- '*.go'

# Review a single historic commit.
commitbrief diff abc1234

# Combine git-side pathspec with CommitBrief's --dir filter.
commitbrief diff HEAD~3 HEAD -- 'src/**' --dir src/handlers

Clone this wiki locally