• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Dev Tips / Git Diff Ignore Mode Changes

Git Diff Ignore Mode Changes

Last updated on November 18, 2019 by Sal Ferrarello

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

The -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.

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Dev Tips, Draft, Solution Tagged With: Git

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in