18

Before I commit some files, how can I see the file permission changes to files? I have some files that git status says had changed and should be added to commit but git diff doesn't show anything. Thanks

Clutch
  • 6,774
  • 10
  • 40
  • 54

4 Answers4

23

git log --summary will get you what you're looking for, I think. The flag will, "Output a condensed summary of extended header information such as creations, renames and mode changes." Note the example below:

$ git log --summary
commit 8978a03a209d1cc4842a8ff14b00253cb7744895
Author: Me
Date:   Wed Feb 23 12:43:30 2011 -0500

    second

 mode change 100644 => 100755 matrix.cc

commit e559dcbee268448d4185854c056174dcb87d3013
Author: Me
Date:   Wed Feb 23 12:43:10 2011 -0500

    first

 create mode 100644 matrix.cc
Jeff Ferland
  • 16,762
  • 5
  • 42
  • 72
17

Well, since the question has been edited to ask something different, here's a different answer:

git status -v will list mode changes as well as diffs. You can filter this down to just mode changes by running it through grep with a context filter: git status -v | grep '^old mode' -C 1 (sample result below)

diff --git a/matrix.cc b/matrix.cc
old mode 100644
new mode 100755
Jeff Ferland
  • 16,762
  • 5
  • 42
  • 72
6

A straightforward answer to your question:

git diff --summary

will output something like this:

mode change 100644 => 100755 assets/README.md
mode change 100644 => 100755 assets/css/app.css
mode change 100644 => 100755 assets/js/app-monitor.js
mode change 100644 => 100755 assets/js/app.js`
Eugen Mihailescu
  • 2,944
  • 1
  • 27
  • 28
  • 1
    And this `git diff --summary | grep --color 'mode change 100644 => 100755' | cut -d' ' -f7 | xargs chmod -x` would remove the execute bit so git doesn't see the files as changed. ref. https://wiki.freephile.org/wiki/Git/hacks#Ignore_File_Mode – Greg Rundlett Jan 13 '19 at 05:03
4

I used this

git status --porcelain=2 | grep '100755 100755 100644' | cut -d' ' -f9

you can change the three masks 100755 100755 100644 with ones you are looking for

MatteoOreficeIT
  • 171
  • 2
  • 4