Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show git diff, ignoring file permission changes?

Tags:

git

git-diff

diff

I have run several chmod in my live server. Right now when I do a git diff there, I see lots of old mode 100644 new mode 100755

I have also changed some files there. But I would just git diff just to show the changes on the files, ignoring the file permissions changes.

How can I do that? BTW, I don't want GIT to ignore those file permissions changes. Actually I want to commit them, I just want git diff to not show them for a very specific moment.

like image 412
Hommer Smith Avatar asked Mar 13 '14 19:03

Hommer Smith


People also ask

How do I ignore permissions in git?

If you set core. filemode=false then git will ignore execute bit changes, no need to change local permissions.

Does git track file permissions?

false : git does not track it.


2 Answers

git diff -G"." 

The -G flag filters out any file where a line that matches a regular expression has not been added or removed. In this case the regular expression provided is "." which matches any line. So the argument -G"." will filter out files where no lines have been added or removed.

You will need (I think) at least Git version 1.7.10 for this to work. 1.7.2 is too old, at least.

like image 151
Zed Avatar answered Sep 23 '22 14:09

Zed


This will tell git to ignore permissions:

git config core.filemode false 

to filter them in result of diff but not ignore them

git filter-branch -f --tree-filter 'find * -type f | xargs chmod 644 ' -- --all 
like image 33
Ashish Chopra Avatar answered Sep 21 '22 14:09

Ashish Chopra