diff --git a/clang/tools/clang-format/git-clang-format b/clang/tools/clang-format/git-clang-format --- a/clang/tools/clang-format/git-clang-format +++ b/clang/tools/clang-format/git-clang-format @@ -40,6 +40,16 @@ between the working directory and , which defaults to HEAD. Changes are only applied to the working directory, or in the stage/index. +Examples: + To format staged changes, i.e everything that's been `git add`ed: + git clang-format + + To also format everything touched in the most recent commit: + git clang-format HEAD~1 + + If you're on a branch off main, to format everything touched on your branch: + git clang-format main + If two commits are given (requires --diff), run clang-format on all lines in the second that differ from the first .