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
Asked
Active
Viewed 2.4k times
18
-
What kind of permissions are you asking about? – Abizern Feb 23 '11 at 17:21
-
File read, write and execute permissions. I'll update the question. – Clutch Feb 23 '11 at 17:25
-
Git only tracks if a file is executable or not. – Arrowmaster Feb 23 '11 at 17:31
-
@Arrowmaster No, it tracks the full set of Unix file permissions. See [this answer](http://stackoverflow.com/questions/737673/how-to-read-the-mode-field-of-git-ls-trees-output) – Abizern Feb 23 '11 at 17:32
-
2@Abizern: While all the output shows full unix file permissions, trust me when I say that 755 and 644 are the only possible permissions it will show. If you don't believe me test it for yourself. – Arrowmaster Feb 23 '11 at 17:38
-
yep - I was trying it for myself and can see it. My bad. – Abizern Feb 23 '11 at 17:40
-
4Dude, changing the question after it's been answered is not a good thing. – Abizern Feb 23 '11 at 22:36
4 Answers
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
![](../../users/profiles/90322.webp)
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
![](../../users/profiles/90322.webp)
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`
![](../../users/profiles/327614.webp)
Eugen Mihailescu
- 2,944
- 1
- 27
- 28
-
1And 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
![](../../users/profiles/2568215.webp)
MatteoOreficeIT
- 171
- 2
- 4