From 32bd773e279eb013cfa24e079e9061871bbe21bd Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 8 Apr 2023 16:43:14 -0400 Subject: [PATCH] Document how to ignore specific files in a diff --- src/git.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/git.md b/src/git.md index a426157a2..34f2f101e 100644 --- a/src/git.md +++ b/src/git.md @@ -508,6 +508,18 @@ See [the docs for `--color-moved`](https://git-scm.com/docs/git-diff#Documentati See [the relevant section for PR authors](#git-range-diff). This can be useful for comparing code that was force-pushed to make sure there are no unexpected changes. +### Ignoring changes to specific files + +Many large files in the repo are autogenerated. To view a diff that ignores changes to those files, +you can use the following syntax (e.g. Cargo.lock): + +``` +git log -p ':!Cargo.lock' +``` + +Arbitrary patterns are supported (e.g. `:!compiler/*`). Patterns use the same syntax as +`.gitignore`, with `:` prepended to indicate a pattern. + ## Git submodules **NOTE**: submodules are a nice thing to know about, but it *isn't* an absolute