开发者

View permissions change in Git

开发者 https://www.devze.com 2023-02-13 12:55 出处:网络
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 sh

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


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


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


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`


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号