When the permissions on a file change in a commit, Git will include this in the diff. Git refers to this as a mode change.
When I’m looking at a
git diff (or specifically a
git diff --name-only where I’m looking for a list of files that have been changed), I often want to ignore mode changes (a.k.a. permission changes). By adding
-G. to the command, mode changes will be ignored.
git diff -G.
How it Works
-G parameter applies a regular expression (in this case
.) to the patch text (the changes in the diff).
The regular expression we are applying (
.) matches any character. Since a mode change (a.k.a. permission change) has no text that has changed, the regular expression will not match (we would need at least one character to match), therefore the mode change is omitted from the diff out.